Skip to content

BUG: Behavior change in pandas 3.x with Series.resample and closed="right", how="right" #62200

@TomAugspurger

Description

@TomAugspurger

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

import pandas as pd
import pandas.testing

index = pd.date_range("1-1-2000", "2-15-2000", freq="h").union(pd.date_range("4-15-2000", "5-15-2000", freq="h"))
s = pd.Series(range(len(index)), index=index)
left = s.resample("D", label="right", closed="right").count()
right = s.resample("24h", label="right", closed="right").count()

pandas.testing.assert_series_equal(left, right)

Issue Description

That program passes without error with pandas==2.3.2, but fails with 3.0.0.dev0+2339.g1af0a95e94. The failure is

AssertionError: Series are different

Series length are different
[left]:  137, DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04',
               '2000-01-05', '2000-01-06', '2000-01-07', '2000-01-08',
               '2000-01-09', '2000-01-10',
               ...
               '2000-05-07', '2000-05-08', '2000-05-09', '2000-05-10',
               '2000-05-11', '2000-05-12', '2000-05-13', '2000-05-14',
               '2000-05-15', '2000-05-16'],
              dtype='datetime64[ns]', length=137, freq='D')
[right]: 136, DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04',
               '2000-01-05', '2000-01-06', '2000-01-07', '2000-01-08',
               '2000-01-09', '2000-01-10',
               ...
               '2000-05-06', '2000-05-07', '2000-05-08', '2000-05-09',
               '2000-05-10', '2000-05-11', '2000-05-12', '2000-05-13',
               '2000-05-14', '2000-05-15'],
              dtype='datetime64[ns]', length=136, freq='24h')

Expected Behavior

Uncertain. I think this is related to #35248 and the fix from #61985. I'm not 100% sure whether the old behavior was buggy and this was a deliberate change. But #35248 mentions "24h" and "1D" behaving differently, so perhaps this is a regresssion.

Installed Versions

INSTALLED VERSIONS
------------------
commit                : 1af0a95e946bfbba814bc5b395cf65047fcac5df
python                : 3.12.8
python-bits           : 64
OS                    : Darwin
OS-release            : 24.6.0
Version               : Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
machine               : arm64
processor             : arm
byteorder             : little
LC_ALL                : None
LANG                  : en_US.UTF-8
LOCALE                : en_US.UTF-8

pandas                : 3.0.0.dev0+2339.g1af0a95e94
numpy                 : 2.4.0.dev0+git20250808.622f874
dateutil              : 2.9.0.post0
pip                   : None
Cython                : None
sphinx                : None
IPython               : 9.4.0
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : None
bottleneck            : None
fastparquet           : None
fsspec                : 2025.3.2
html5lib              : None
hypothesis            : 6.136.1
gcsfs                 : None
jinja2                : 3.1.6
lxml.etree            : None
matplotlib            : 3.10.3
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : None
psycopg2              : None
pymysql               : None
pyarrow               : 21.0.0
pyiceberg             : None
pyreadstat            : None
pytest                : 8.4.1
python-calamine       : None
pytz                  : 2025.2
pyxlsb                : None
s3fs                  : 2025.7.0
scipy                 : None
sqlalchemy            : 2.0.41
tables                : None
tabulate              : None
xarray                : None
xlrd                  : None
xlsxwriter            : None
zstandard             : None
qtpy                  : None
pyqt5                 : None


Metadata

Metadata

Assignees

Labels

BugNeeds TriageIssue that has not been reviewed by a pandas team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions