-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Week Start/End Resamping: WS/WE frequencies #15449
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
Conversation
With the above changes, the alias works for my original scenario: import pandas as pd
df = pd.DataFrame(pd.date_range('2016-02-01', '2016-02-29').rename('dt'))
df['val'] = 1
df.groupby(pd.Grouper(key='dt',freq='WS'))['val'].sum()
dt
2016-02-01 7
2016-02-08 7
2016-02-15 7
2016-02-22 7
2016-02-29 1
Freq: WS-MON, Name: val, dtype: int64 as well as OP's: import pandas as pd
import datetime as dt
daily_daterange = pd.date_range(start=dt.datetime(2013, 1, 31),
end=dt.datetime(2013,2,28),
freq='B')
daily_dataset = pd.DataFrame({'value' : range(len(daily_daterange))}, index=daily_daterange)
# week begin bound to monday
daily_dataset.resample('WS-MON').mean()
Out[460]:
value
2013-01-28 0.5
2013-02-04 4.0
2013-02-11 9.0
2013-02-18 14.0
2013-02-25 18.5
# week end bound to sunday
daily_dataset.resample('W-SUN').mean()
Out[461]:
value
2013-02-03 0.5
2013-02-10 4.0
2013-02-17 9.0
2013-02-24 14.0
2013-03-03 18.5 However, it raises some questions:
|
Some initial thoughts:
As you note -
Not ideal, but not sure if there's a better name.
Aliases are likely used more, for ranges and resampling, but at least personally, I use offsets fairly frequently for shifting dates.
|
I wonder how often people use something like:
It seems like |
@aiguofer love to have this, but will need quite a bit of testing. |
Yeah... I haven't had time to get back to this. I'd really like to follow the Boy Scout Rule, but indeed that probably means changing some things, and writing lots of tests. Hopefully I'll have some time to get back to this in the coming weeks. |
closing as stale |
This is just some initial work to start the conversation.
git diff upstream/master | flake8 --diff