glucopy.disjoin_days_and_hours#
- glucopy.disjoin_days_and_hours(df, date_column: str | int = 0, cgm_column: str | int = 1, date_format: str | None = None)[source]#
Disjoins a dataframe with a column with datetime objects into a dataframe with columns for day, time and cgm values
- Parameters:
df (pd.DataFrame) – DataFrame to disjoin
date_column (str or int, default 0) – Column name or index with datetime objects
cgm_column (str or int, default 1) – Column name or index with cgm values
date_format (str, default None) – Format of the date information, if None, it will be assumed that the date information is in a consistent format
- Returns:
disjoined_df – Disjoined dataframe
- Return type:
pd.DataFrame
Examples
Disjoin a dataframe
In [1]: import glucopy as gp In [2]: import pandas as pd In [3]: df = pd.DataFrame({'Timestamp':['2020-01-01 12:00:00','2020-01-01 12:05:00','2020-01-01 12:10:00'], ...: 'CGM':[100,110,120]}) ...: In [4]: gp.disjoin_days_and_hours(df) Out[4]: Timestamp Day Time CGM 0 2020-01-01 12:00:00 2020-01-01 12:00:00 100 1 2020-01-01 12:05:00 2020-01-01 12:05:00 110 2 2020-01-01 12:10:00 2020-01-01 12:10:00 120