-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
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
index=pd.date_range('2025-10-25', '2025-10-26', freq='d', tz='Europe/Helsinki')
index2=pd.date_range('2025-10-25', '2025-10-28', freq='d', tz='Europe/Helsinki')
index.union(index2)Issue Description
index union fails when one index ends when day-light saving time ends and the other index contains timestamps after the transition.
The error comes from assert in pandas/core/indexes/datetimelike.py", line 703, in _fast_union
assert dates._freq == self.freq # type: ignore[union-attr]
After debugging the root cause is the following check when concatenating the indices
pandas/pandas/core/arrays/datetimelike.py
Line 2386 in 54c26ec
| if all(pair[0][-1] + obj.freq == pair[1][0] for pair in pairs): |
When that check fails, like it does in the example, the frequency of the index is set None resulting in failing assert in _fast_union
Expected Behavior
The index union succeeds
Installed Versions
INSTALLED VERSIONS
commit : 9c8bc3e
python : 3.13.5
python-bits : 64
OS : Linux
OS-release : 6.14.4-300.fc42.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Fri Apr 25 15:43:38 UTC 2025
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.3.3
numpy : 2.2.6
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.2
Cython : None
sphinx : 8.2.3
IPython : 9.4.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : 6.136.9
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.5
numba : 0.61.2
numexpr : 2.10.2
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : 2.9.10
pymysql : None
pyarrow : None
pyreadstat : None
pytest : 8.4.1
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.16.0
sqlalchemy : 2.0.42
tables : 3.10.2
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : 0.23.0
tzdata : 2025.2
qtpy : None
pyqt5 : None