-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Odd behavior with .resample('SM') #14888
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
Comments
@adrienemery - thoughts? |
This has to do with the default behaviour of Source: https://github.com/pandas-dev/pandas/blob/v0.19.1/pandas/tseries/resample.py#L985-L997 Notice if you use the print(example.set_index('date').resample('MS').last())
# Output
#
# aux
# date
# 2000-01-01 2000-01-31
# 2000-02-01 2000-02-29
# 2000-03-01 2000-03-31 If you want the behaviour you desire you need to pass in print(example.set_index('date').resample('SM', label='right').last())
# Output
#
# aux
# date
# 2000-01-15 2000-01-14
# 2000-01-31 2000-01-28
# 2000-02-15 2000-02-14
# 2000-02-29 2000-02-28
# 2000-03-15 2000-03-14
# 2000-03-31 2000-03-30
# 2000-04-15 2000-03-31 For more on bin labels and what side to close bins look at the examples in the resample documentation here: Hopefully this clears it up. |
good explanation. can you add (a shorter) example like this to the docs (and to the doc-string if it will fit, though maybe a link to the doc section is better). |
@adrienemery thank you, the explanation was very clear.
|
Code Sample, a copy-pastable example if possible
Problem description
When resampling with 'SM' the values in the 'aux' column have ocurred after or at the resampling date, whereas with 'M' or 'W' (or 'Q', or 'A'...) the values in the 'aux' columns have ocurred before or at the resampling date.
Expected Output
The expected output form the 'SM' resample would be:
Output of
pd.show_versions()
pandas: 0.19.1
nose: 1.3.7
pip: 9.0.1
setuptools: 20.3
Cython: 0.22.1
numpy: 1.11.1
scipy: 0.18.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.0
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: 1.0.0
tables: 3.2.0
numexpr: 2.5.2
matplotlib: 1.4.3
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 1.0.0
xlsxwriter: 0.7.3
lxml: 3.4.4
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.8
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: