Update for pandas==2.0.2 compatibility Issue #258 #260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.