Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check_group_daterange function in preprocessor.py #555

Closed
wants to merge 8 commits into from
11 changes: 11 additions & 0 deletions src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,17 @@
"""
date_col = "date_range"
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
Loading