Skip to content

Commit

Permalink
MAINT, BUG: pandas 2.0 compatibility
Browse files Browse the repository at this point in the history
Fixes darshan-hpc#909

* make the library compatible with both `pandas 1.5.x` and `pandas
2.0.0rc0` by pinning the dtype we use for one-hot encoding our heatmap
data

* see related upstream comment and release notes (`get_dummies()`
change):
  - pandas-dev/pandas#48022 (comment)
  - https://pandas.pydata.org/pandas-docs/version/2.0/whatsnew/v2.0.0.html
  • Loading branch information
tylerjereddy committed Feb 28, 2023
1 parent eb404fe commit 7428e01
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,12 @@ def get_heatmap_df(agg_df: pd.DataFrame, xbins: int, nprocs: int) -> pd.DataFram
bin_edge_data = np.linspace(0.0, max_time, xbins + 1)
# create dummy variables for start/end time data, where dataframe columns
# are the x-axis bin ranges
# pin dtype here because of pandas 2.0+ change--see:
# gh-909 and
# https://github.com/pandas-dev/pandas/pull/48022#issuecomment-1448755561
cats_start = pd.get_dummies(
pd.cut(agg_df["start_time"], bin_edge_data, precision=16)
pd.cut(agg_df["start_time"], bin_edge_data, precision=16),
dtype=np.uint8,
)
cats_end = pd.get_dummies(pd.cut(agg_df["end_time"], bin_edge_data, precision=16))
# get series for the elapsed times for each dxt segment
Expand Down

0 comments on commit 7428e01

Please sign in to comment.