-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
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
left = pd.DatetimeIndex(['2021-12-11 01:05:00'], dtype='datetime64[us]', freq='5min')
right = pd.DatetimeIndex(['2021-12-11 01:05:00', '2021-12-11 01:10:00'], dtype='datetime64[us]', freq='5min')
left.union(right)
Issue Description
Ouput of the example is:
DatetimeIndex(['2021-12-11 01:05:00', '2021-12-14 12:25:00'], dtype='datetime64[us]', freq='5min')
'2021-12-14 12:25:00' doesn't exists in input indices.
The bug doesn't appear if nanoseconds are used as dtype or if at least one frequency is not specified.
Expected Behavior
output should be:
DatetimeIndex(['2021-12-11 01:05:00', '2021-12-11 01:10:00'], dtype='datetime64[us]', freq='5min')
or
DatetimeIndex(['2021-12-11 01:05:00', '2021-12-11 01:10:00'], dtype='datetime64[us]', freq=None)
Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.12.4.final.0
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.2.2
numpy : 2.0.0
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.5.1
pip : 24.0
Cython : None
pytest : 8.2.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.6.0
gcsfs : None
matplotlib : None
numba : 0.60.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 16.1.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None