Skip to content

Commit

Permalink
fix(tdis.py::aggregate_dataframe_to_stress_period): cast start_dateti…
Browse files Browse the repository at this point in the history
…me and end_datetime cols to datetime64[ns] so that pd.concat doesn't fail with heterogenous dtypes
  • Loading branch information
aleaf committed Sep 21, 2023
1 parent d5638b5 commit 7c2d289
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mfsetup/tdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,11 @@ def aggregate_dataframe_to_stress_period(data, id_column, data_column, datetime_
aggregated.reset_index(inplace=True)

# add datetime back in
aggregated['start_datetime'] = pd.Timestamp(start) if start is not None else start_datetime
aggregated['start_datetime'] = start if start is not None else start_datetime
# enforce consistent datetime dtypes
# (otherwise pd.concat of multiple outputs from this function may fail)
for col in 'start_datetime', 'end_datetime':
aggregated[col] = aggregated[col].astype('datetime64[ns]')

# drop original datetime column, which doesn't reflect dates for period averages
drop_cols = [datetime_column]
Expand Down

0 comments on commit 7c2d289

Please sign in to comment.