We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
closed=right
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
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
In [1]: import pandas as pd In [2]: index = pd.Series([pd.Timedelta(seconds=120 + i * 30) for i in range(10)]) In [3]: series = pd.Series(range(10), index=index) In [4]: series Out[4]: 0 days 00:02:00 0 0 days 00:02:30 1 0 days 00:03:00 2 0 days 00:03:30 3 0 days 00:04:00 4 0 days 00:04:30 5 0 days 00:05:00 6 0 days 00:05:30 7 0 days 00:06:00 8 0 days 00:06:30 9 dtype: int64 In [5]: series.resample('T', closed='left', label='left').sum() Out[5]: 0 days 00:02:00 1 0 days 00:03:00 5 0 days 00:04:00 9 0 days 00:05:00 13 0 days 00:06:00 17 Freq: T, dtype: int64 In [6]: series.resample('T', closed='right', label='right').sum() # WRONG! Out[6]: 0 days 00:02:00 1 0 days 00:03:00 5 0 days 00:04:00 9 0 days 00:05:00 13 0 days 00:06:00 17 Freq: T, dtype: int64
closed=right argument takes no effect, the output is same as closed=left.
closed=left
The same computation on a DatetimeIndex, which is the expected behavior:
DatetimeIndex
In [7]: index = pd.Series([pd.Timedelta(seconds=120 + i * 30) for i in range(10)]) In [8]: index = index + pd.to_datetime('2000-01-01') In [9]: series = pd.Series(range(10), index=index) In [10]: series Out[10]: 2000-01-01 00:02:00 0 2000-01-01 00:02:30 1 2000-01-01 00:03:00 2 2000-01-01 00:03:30 3 2000-01-01 00:04:00 4 2000-01-01 00:04:30 5 2000-01-01 00:05:00 6 2000-01-01 00:05:30 7 2000-01-01 00:06:00 8 2000-01-01 00:06:30 9 dtype: int64 In [11]: series.resample('T', closed='left', label='left').sum() Out[11]: 2000-01-01 00:02:00 1 2000-01-01 00:03:00 5 2000-01-01 00:04:00 9 2000-01-01 00:05:00 13 2000-01-01 00:06:00 17 Freq: T, dtype: int64 In [12]: series.resample('T', closed='right', label='right').sum() # RIGHT Out[12]: 2000-01-01 00:02:00 0 2000-01-01 00:03:00 3 2000-01-01 00:04:00 7 2000-01-01 00:05:00 11 2000-01-01 00:06:00 15 2000-01-01 00:07:00 9 Freq: T, dtype: int64
commit : 66e3805 python : 3.8.8.final.0 python-bits : 64 OS : Linux OS-release : 4.9.130-0409130-generic Version : #201809291131 SMP Sat Sep 29 11:33:40 UTC 2018 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : None LOCALE : en_US.UTF-8
pandas : 1.3.5 numpy : 1.19.5 pytz : 2021.1 dateutil : 2.8.1 pip : 21.0.1 setuptools : 52.0.0.post20210125 Cython : None pytest : 6.2.3 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : 1.0.2 psycopg2 : None jinja2 : 2.11.3 IPython : 7.22.0 pandas_datareader: None bs4 : None bottleneck : None fsspec : 0.9.0 fastparquet : 0.7.1 gcsfs : None matplotlib : 3.3.4 numexpr : None odfpy : None openpyxl : 3.0.7 pandas_gbq : None pyarrow : 6.0.1 pyxlsb : None s3fs : None scipy : 1.6.2 sqlalchemy : 1.4.23 tables : None tabulate : 0.8.9 xarray : 0.19.0 xlrd : 2.0.1 xlwt : None numba : 0.53.1
The text was updated successfully, but these errors were encountered:
#40245 should deprecate this arg in favour of inclusive
inclusive
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
closed=right
argument takes no effect, the output is same asclosed=left
.Expected Behavior
The same computation on a
DatetimeIndex
, which is the expected behavior:Installed Versions
INSTALLED VERSIONS
commit : 66e3805
python : 3.8.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.9.130-0409130-generic
Version : #201809291131 SMP Sat Sep 29 11:33:40 UTC 2018
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.3.5
numpy : 1.19.5
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 52.0.0.post20210125
Cython : None
pytest : 6.2.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.9.0
fastparquet : 0.7.1
gcsfs : None
matplotlib : 3.3.4
numexpr : None
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 6.0.1
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.23
tables : None
tabulate : 0.8.9
xarray : 0.19.0
xlrd : 2.0.1
xlwt : None
numba : 0.53.1
The text was updated successfully, but these errors were encountered: