-
Notifications
You must be signed in to change notification settings - Fork 33
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
implement pyleo.Series.resample #303
Conversation
Resolves: LinkedEarth/paleoPandas#12 |
@@ -1 +1,2 @@ | |||
environment.yml merge=ours | |||
*.py diff=python |
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.
this was just to allow git log
to work with Python functions
pyleoclim/utils/tsutils.py
Outdated
@@ -76,7 +76,7 @@ def time_unit_to_datum_exp_dir(time_unit, time_name=None): | |||
exponent = 9 | |||
direction = 'retrograde' | |||
else: | |||
warnings.warn(f'Time unit {time_unit} not recognized. Defaulting to years CE') | |||
warnings.warn(f'Time unit {time_unit} not recognized. Defaulting to years CE', stacklevel=4) |
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.
this is so that the warning will point to the user's code, rather than to the line of code within pyleoclim which raises the warning
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. That is useful as this warning was cropping up constantly on my end due to my inadequate parsing of units (now fixed). I could make sense of it because I know the code, but this should help other users figure out what's happening on their end.
Hi @MarcoGorelli , the tests exchanged on Slack look good: I added a modification to the metadata to indicate that resampling had taken place. However, it would be good to add that to the log as well. You can look at Series.center() as an example of what the log does: indicate what transformation was applied and keep track of some relevant bits (not sure what this would be there; maybe the original index?) Note that your docstring example was a tad terse for our users: I replaced with:
Pandas question: I see that the method returns a SeriesResampler object, which I have never encountered. beyond Once that is all resolved, I am happy to merge and we can wait until pandas issue 51024 is addressed for the longer-term stuff. PS: feel free to review this review! |
I think so - don't you have a way of building the docs locally? then you could check |
add resample rule information to series label if present
The checks have failed : Perhaps testing for the equality of the entire metadata dict is too much? It looks like "clean()" is applied 3 times here, and perhaps a 4th that is not taken into account in the test? |
It's just how like if you have a pandas Series, and you just call In [1]: ser = pd.Series([1, 2, 3, 4, 5], index=pd.date_range('2000', periods=5))
In [2]: ser.resample('Y')
Out[2]: <pandas.core.resample.DatetimeIndexResampler object at 0x7fa4e50493d0> Regarding what works with it - any aggregation that works on a pandas.Series.resample should work, see https://pandas.pydata.org/docs/user_guide/timeseries.html#resampling e.g. |
Thanks for the explanation Marco. This checks all the boxes so I am going to merge. I need to educate myself on resample() to make the best of it, and the link really helps. I wonder how this can help us for aligning Series objects within a MultipleSeries. We have a method under the latter class called |
Here's a start on pyleo.Series.resample
This allows you to do
instead of
, but also to use
'Ga'
/'Ka'
/ etc. (or at least, it will once pandas-dev/pandas#51024 is addressed)