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 ad68245 commit db03604
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mfsetup/tdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,12 @@ 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':
if col in aggregated.columns:
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 db03604

Please sign in to comment.