-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add a feature to swap_year_for_time
#560
Add a feature to swap_year_for_time
#560
Conversation
Codecov Report
@@ Coverage Diff @@
## main #560 +/- ##
=======================================
- Coverage 93.6% 93.6% -0.1%
=======================================
Files 50 50
Lines 5283 5313 +30
=======================================
+ Hits 4950 4978 +28
- Misses 333 335 +2
Continue to review full report at Codecov.
|
@loeffko @sebastianzwickl @erikfilias, this may be helpful for your ongoing work in the model linkage for openENTRANCE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My one quick thought. Lots of edge cases could be covered here, depends how widely this feature is expected to be used.
""" | ||
return swap_time_for_year(self, subannual=subannual, inplace=inplace) | ||
|
||
def swap_year_for_time(self, inplace=False): | ||
"""Convert the `year` and `subannual` dimensions to `time` (as datetime). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding that the conversion is done using dateutil.parser.parse
on the combination of year and subannual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, great suggestion - added this to the docstring including intersphinx mapping...
The unit tests already cover five basic cases, including the one we are using in the openENTRANCE and ECEMF projects - this is the one where I see this function actually being used. I don't see any other use cases on the horizon (like using a different column name than "subannual" for the non-year parts, or using several columns) - but no reason why these two "swap" functions couldn't be extended in that direction with keyword arguments... |
Merging as there were no objections or further comments... Thanks @znicholls for the suggestion to improve the docs! |
Please confirm that this PR has done the following:
Name of contributors Added to AUTHORS.rstDescription of PR
This PR introduces the "inverse" of the
swap_time_for_year()
method. This should facilitate conversion from and to properdatetime
timeseries and the "subannual" column currently used in the IIASA database infrastructure.As shown in the tests, if you have an IamDataFrame with datetime format, then
will yield an identical object.