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

Update for pandas==2.0.2 compatibility Issue #258 #260

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

DaveCasson
Copy link
Contributor

Two changes to address issues with updated pandas.

First change: Updated date_range function to support inclusive parameter

Details:
The date_range function has been modified to include the inclusive parameter which controls whether to set each bound as closed or open. This parameter replaces the closed parameter which previously served a similar purpose.

The possible values for the inclusive parameter are:

"both": Both bounds are closed (inclusive).
"neither": Both bounds are open (exclusive).
"left": The left bound is closed (inclusive) and the right bound is open (exclusive).
"right": The right bound is closed (inclusive) and the left bound is open (exclusive).

This updates a default argument, which does not appear to require modification to any other function calls in MetSim. This could be checked further.

Second change: Refactored pd.Timedelta in ds['time'] calculation

Details:
The line of code that modifies the 'time' field in the ds dataframe has been updated. The code now uses the named parameter version of the pd.Timedelta function instead of the string-based version.

Previously, the timedelta of '11 hours, 59 minutes, and 59 seconds' was represented as a string '11H59M59S'. The new version of the code provides the hours, minutes, and seconds as explicit arguments. This avoids an issue and raised with the ambuiguity of 'M'.

ds['time'] = (ds.indexes['time'] - pd.Timedelta(hours=11, minutes=59, seconds=59)

These changes were tested only in a local, personal MetSim workflow with pandas==2.0.2.

Two changes to address issues with updated pandas.
This was tested in a local, personal MetSim workflow with pandas==2.0.2

First change: Updated date_range function to support inclusive parameter

Details:
The date_range function has been modified to include the inclusive parameter which controls whether to set each bound as closed or open. This parameter replaces the closed parameter which previously served a similar purpose.

The possible values for the inclusive parameter are:

"both": Both bounds are closed (inclusive).
"neither": Both bounds are open (exclusive).
"left": The left bound is closed (inclusive) and the right bound is open (exclusive).
"right": The right bound is closed (inclusive) and the left bound is open (exclusive).

This updates a default argument, which does not appear to require modification to any other function calls in MetSim. This could be checked further.

Second change: Refactored pd.Timedelta in ds['time'] calculation

Details:
The line of code that modifies the 'time' field in the ds dataframe has been updated. The code now uses the named parameter version of the pd.Timedelta function instead of the string-based version.

Previously, the timedelta of '11 hours, 59 minutes, and 59 seconds' was represented as a string '11H59M59S'. The new version of the code provides the hours, minutes, and seconds as explicit arguments. This avoids an issue and raised with the ambuiguity of 'M'.

ds['time'] = (ds.indexes['time'] - pd.Timedelta(hours=11, minutes=59, seconds=59)
@DaveCasson DaveCasson changed the title Update for pandas==2.0.2 compatibility Update for pandas==2.0.2 compatibility Issue #258 Aug 3, 2023
@arbennett arbennett merged commit b4b5929 into UW-Hydro:develop Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants