-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Create a generic version of convert_to_annual function in scikits.timeseries #736
Comments
Link to scikits.timeseries meta issue: |
* timeseries: (200 commits) TST: don't use deprecated DateRange BUG: fix buglets surfacing from merge RLS: set released to false, bump dev version to 0.8.0 BUG: fix major performance issue in DatetimeIndex.union affecting join performance on irregular indexes, remedying #1046 ENH: add to_datetime method to Index, close #208 ENH: legacy time rule support and refactoring, better alias handling. misc tests, #1041 ENH: to_datetime will convert array of strings and NAs to datetime64 with NaT, close #999 ENH: more datetime64 integration in core data algorithms per #996, close #1035 ENH: handle datetime64 in block formation from dict of arrays in DataFrame constructor, close #1037 BUG: fix broken time_rule usage in legacy DateRange, close #1036 BUG: name inline method something different ENH: initial version of convert_to_annual for pandas, #736 BUG: convert datetime64 -> datetime.datetime for matplotlib, close #1003 ENH: integrate cython ohlc in groupby and test, close #152 ENH: implement Cython OHLC function for groupby #152 ENH: use cython bin groupers, fix bug in DatetimeIndex.__getitem causing slowness, some timeseries vbenches ENH: enable to_datetime to be vectorized, handle NAs, close #858 TST: interactions between array of datetime objects and DatetimeIndex, bug fixes TST: remove errant foo and test_datetime64.py TST: moved test_datetime64.py tests to test_timeseries ...
This kind of stuff would be nice to be able to do too: http://stackoverflow.com/questions/10458493/pandas-how-to-plot-yearly-data-on-top-of-each-other |
Is it planned to integrate this into 0.8 final? |
No, we pushed this off to 0.9.0 for now |
@timmie: there is a version of it already in pandas/tseries/util.py, but I need people like you to give me some more guidance on what features of it are actually required (we're talking about a 15 line function here). I suspect that pandas's groupby capability makes |
OK, very nice. Is it also possible to do such operations on dataframes? |
Wouldn't |
Or otherwise |
Please help, I am getting the following errors:
|
Please addd util to namespace
|
I suspect that
Does not achieve a equal alignement over years for all parameters as commented in #736 (comment) |
Why wouldn't it? |
Hmm. I feel I need to set up a Ipython notebook somewhere to have a test playground. |
And what would the NotImplementedError(freq) mean? |
If you look at the source for |
You should also try |
OK, I see. Then there must be a misunderstanding here. did you try ts.convert_to_annual with a timeseries of hourly frequency covering at > 1 year? |
You're computing means over years or over hours? If I understand correctly now you want the mean value for each hour of the year across the data set? I agree that you can do that with |
Yes. Could alos apply for daily, etc.
Agree. I will come up with an example data soon. |
Here's the code:
I also have this as htmlnotebook file and print but I donno how to attach here. |
Here is the pandas equivalent for daily data (one of the implemented frequencies) using
I'll see if I can find the time in the next 10 days to finish the other frequencies--- the hardest part is writing test cases, honestly. |
The htmlnotebook is now at:
Happy to read that we talked about teh same idea and purpose of the fuction. For 0.9 I could see soem more improvements: although not being associated with a certain year, ths data is still datetime (months, days, hours, etc.). This is linked with my comment on the plots: But one after the other. |
Could you give some guidance for adding higher frequencies? |
While I am trying to get moving on the hourly freq., I still would like to get an opinion from @wesm Why did we not copy the method at: Thanks in advance & sorry if I am too pushy on this. |
That method needs quite a bit of work to be adapted to work with pandas-- I already started doing it but ran out of time. It's just a matter of time and resources--note that you are the only person to ever bring this up with us. |
Noted that. And started to expand it by myself.
Allow one more question: So would you suppose: Others do not need this functionality or they just have their own function based n what already exists within pandas? |
I finally got a working solution for the hourly frequency. But it diverts a but from the existing function. I found that using years as rows and hours (of the year) as columns is difficult in e.g. excel. So I transposed the thing. How would be best proceed. Shall I share a working example via email? If you are fine, I would then try to make a test and prepare a qualified PR. BTW: let's rename this issue to "Create a generic version of convert_to_annual function in scikits.timeseriesfinalise in pivot_annual". This way it would get found found better under the right topic. |
I have a code up for the hourly frequency. please look at #2153 |
Sorry about digging something old as this, but is there a way to do year over year aggregation directly? |
maybe show an example of what you are looking |
@ispmarin Answered in so. Can you check? |
Sure. Gonna test and will report back. |
Works. Thanks! This should be in the manual somewhere. It seems to be a very common question on stack overflow and very useful on financial circles. |
@sinhrks let's add this recipe to ththe cookbook and close this issue then |
I can help writing the docs, if needed. |
@ispmarin that would be gr8!. |
BTW, we do have a |
Thanks for help, @ispmarin
|
So where do this issue stands? Is the answer on stack overflow the right way to do this, or there is another way? |
yes, @sinhrks 's answer at stackoverflow is the way to go |
Ok, got it. How is the best way to create the doc? Create a ipython notebook, annotated? Is there any guidelines for it? |
Can this issue be closed? |
idea was to add a recipe in the cookbook |
The name is a misnomer. It's really a pivot operation
The text was updated successfully, but these errors were encountered: