5. Sub-package dataframes¶
Provide tools to manage dataframes in the context of calibration.
It contains the following python modules:
Module dfdicts¶
Perform type-conversion and pretty-print operations for dictionaries.
It contains the following functions:
- pvlab.dataframes.dfdicts.dict_to_df(dictionary: dict, columns: list) pandas.core.frame.DataFrame ¶
Re-arrange a dictionary to become a pandas dataframe.
It performs a type conversion of a dictionary (e.g. a dictionary that represents some kind of valid time intervals), returning a
pandas
DataFrame.Example 1: correct functioning.
>>> dates = {'START_1': (2021,5,5,8,1,0), 'END_1': (2021,5,6,22,52,0)}
>>> columns = ['%Y', '%m', '%d', '%H', '%M', '%S']
>>> dict_to_df(dates, columns) %Y %m %d %H %M %S START_1 2021 5 5 8 1 0 END_1 2021 5 6 22 52 0
Example 2: the columns list is too short.
>>> columns = ['%Y', '%m', '%d', '%H', '%M']
>>> dict_to_df(dates, columns) Traceback (most recent call last): ... ValueError: Length of columns list is equal to 5, but has to be equal to 6.
Example 3: the columns list is too long.
>>> columns = ['%Y', '%m', '%d', '%H', '%M', '%S', '%mS']
>>> dict_to_df(dates, columns) Traceback (most recent call last): ... ValueError: Length of columns list is equal to 7, but has to be equal to 6.
- pvlab.dataframes.dfdicts.print_dict(dictionary: dict, columns: list, title: str = '') None ¶
Prettyprint a dictionary of dates, adding a title.
Example: correct functioning.
>>> dates = {'START_1': (2021,5,5,8,1,0), 'END_1': (2021,5,6,22,52,0)}
>>> columns = ['%Y', '%m', '%d', '%H', '%M', '%S']
>>> title = 'Valid time intervals'
>>> print_dict(dates, columns, title) Valid time intervals -------------------- %Y %m %d %H %M %S START_1 2021 5 5 8 1 0 END_1 2021 5 6 22 52 0