cowidev.grapher.files#

cowidev.grapher.files.explorer#

class cowidev.grapher.files.explorer.Exploriser(location: str = 'location', date: str = 'date', pivot_column: str = None, pivot_values: str = None, function_input: Callable = <function Exploriser.<lambda> at 0x7f05468f4ca0>, function_output: Callable = <function Exploriser.<lambda> at 0x7f05468f4dc0>)[source]#

Bases: object

date: str = 'date'#
function_input()#
function_output()#
location: str = 'location'#
pipe_nan_to_none(df: DataFrame) DataFrame[source]#
pipe_pivot(df: DataFrame) DataFrame[source]#
pipe_to_dict(df: DataFrame) DataFrame[source]#
pipeline(df: DataFrame) dict[source]#
pivot_column: str = None#
pivot_values: str = None#
read(input_path: str)[source]#
run(input_path: str, output_path: str)[source]#
to_json(obj)[source]#

cowidev.grapher.files.grapher#

class cowidev.grapher.files.grapher.Grapheriser(location: str = 'location', date: str = 'date', date_ref: datetime.datetime = datetime.datetime(2020, 1, 21, 0, 0), fillna: bool = False, fillna_0: bool = True, pivot_column: str = None, pivot_values: str = None, suffixes: list = None, function_input: Callable = <function Grapheriser.<lambda> at 0x7f05468e6b80>, function_output: Callable = <function Grapheriser.<lambda> at 0x7f05468e6c10>, columns_non_fillna_0: list = <factory>)[source]#

Bases: object

columns_data(df: DataFrame) list[source]#
property columns_metadata: list#
columns_non_fillna_0: list#
date: str = 'date'#
date_ref: datetime = datetime.datetime(2020, 1, 21, 0, 0)#
property do_pivot#
fillna: bool = False#
fillna_0: bool = True#
function_input()#
function_output()#
location: str = 'location'#
property metric2suffix: dict#
pipe_fillna(df: DataFrame) DataFrame[source]#
pipe_metadata_columns(df: DataFrame) DataFrame[source]#

Rename columns and convert date to Year grapher metric.

pipe_normalize_columns(df)[source]#

Normalize column names.

If columns are multiindex (of length 2), use first and second positions to create new column name.

This only applies if pivot has been done, i.e. pivot_column and pivot_values are not None.

pipe_order_columns(df: DataFrame) DataFrame[source]#

Re-order the columns of the dataframe.

First columns are [Country, Year]

pipe_pivot(df: DataFrame) DataFrame[source]#

Pivot values of columns of interest.

pipeline(df: DataFrame)[source]#
pivot_column: str = None#
pivot_values: str = None#
property pivot_values_list: list#
read(input_path: str)[source]#
run(input_path: str, output_path: str)[source]#
suffixes: list = None#
property suffixes_list: list#
class cowidev.grapher.files.Exploriser(location: str = 'location', date: str = 'date', pivot_column: str = None, pivot_values: str = None, function_input: Callable = <function Exploriser.<lambda> at 0x7f05468f4ca0>, function_output: Callable = <function Exploriser.<lambda> at 0x7f05468f4dc0>)[source]#

Bases: object

date: str = 'date'#
function_input()#
function_output()#
location: str = 'location'#
pipe_nan_to_none(df: DataFrame) DataFrame[source]#
pipe_pivot(df: DataFrame) DataFrame[source]#
pipe_to_dict(df: DataFrame) DataFrame[source]#
pipeline(df: DataFrame) dict[source]#
pivot_column: str = None#
pivot_values: str = None#
read(input_path: str)[source]#
run(input_path: str, output_path: str)[source]#
to_json(obj)[source]#
class cowidev.grapher.files.Grapheriser(location: str = 'location', date: str = 'date', date_ref: datetime.datetime = datetime.datetime(2020, 1, 21, 0, 0), fillna: bool = False, fillna_0: bool = True, pivot_column: str = None, pivot_values: str = None, suffixes: list = None, function_input: Callable = <function Grapheriser.<lambda> at 0x7f05468e6b80>, function_output: Callable = <function Grapheriser.<lambda> at 0x7f05468e6c10>, columns_non_fillna_0: list = <factory>)[source]#

Bases: object

columns_data(df: DataFrame) list[source]#
property columns_metadata: list#
columns_non_fillna_0: list#
date: str = 'date'#
date_ref: datetime = datetime.datetime(2020, 1, 21, 0, 0)#
property do_pivot#
fillna: bool = False#
fillna_0: bool = True#
function_input()#
function_output()#
location: str = 'location'#
property metric2suffix: dict#
pipe_fillna(df: DataFrame) DataFrame[source]#
pipe_metadata_columns(df: DataFrame) DataFrame[source]#

Rename columns and convert date to Year grapher metric.

pipe_normalize_columns(df)[source]#

Normalize column names.

If columns are multiindex (of length 2), use first and second positions to create new column name.

This only applies if pivot has been done, i.e. pivot_column and pivot_values are not None.

pipe_order_columns(df: DataFrame) DataFrame[source]#

Re-order the columns of the dataframe.

First columns are [Country, Year]

pipe_pivot(df: DataFrame) DataFrame[source]#

Pivot values of columns of interest.

pipeline(df: DataFrame)[source]#
pivot_column: str = None#
pivot_values: str = None#
property pivot_values_list: list#
read(input_path: str)[source]#
run(input_path: str, output_path: str)[source]#
suffixes: list = None#
property suffixes_list: list#