Skip to content

Commit

Permalink
fix check_group_daterange function in preprocessor.py (#568)
Browse files Browse the repository at this point in the history
* fix conditional in datelabel.py

* fix check_group_daterange function in preprocessor.py
  • Loading branch information
jtmims authored May 20, 2024
1 parent 06791bf commit bac9746
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,17 @@ def check_group_daterange(self, group_df: pd.DataFrame, log=_log) -> pd.DataFram
if not hasattr(group_df, 'start_time') or not hasattr(group_df, 'end_time'):
raise AttributeError('Data catalog is missing attributes `start_time` and/or `end_time`')
try:
if not isinstance(group_df['start_time'].values[0], datetime.date):
# convert int to date type
date_format = ''
date_digits = math.floor(math.log10(group_df['start_time'].values[0]))+1
match date_digits:
case 8:
date_format = '%Y%m%d'
case 14:
date_format = '%Y%m%d%H%M%S'
group_df['start_time'] = pd.to_datetime(group_df['start_time'].values[0], format=date_format)
group_df['end_time'] = pd.to_datetime(group_df['end_time'].values[0], format=date_format)
# method throws ValueError if ranges aren't contiguous
dates_df = group_df.loc[:, ['start_time', 'end_time']]
date_range_vals = []
Expand Down

0 comments on commit bac9746

Please sign in to comment.