BUG: date_range(freq='Y') is missing a date · Issue #56134 · pandas-dev/pandas (original) (raw)
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 pd.date_range(start=pd.to_datetime('2021-12-31 00:00:01'), end=pd.to_datetime('2023-11-01 00:00:00'), freq='Y')
>> DatetimeIndex(['2021-12-31 00:00:01'], dtype='datetime64[ns]', freq='A-DEC')
### Issue Description
This Year-End (freq='Y') date range is skipping one date (missing '2022-12-31 00:00:01').
When using start='2021-12-31' the behavior is nominal, the bug only appears when using a non-round datetime.
### Expected Behavior
`DatetimeIndex(['2021-12-31 00:00:01', '2022-12-31 00:00:01'], dtype='datetime64[ns]', freq='A-DEC')`
### Installed Versions
<details>
INSTALLED VERSIONS
------------------
commit : 2a953cf80b77e4348bf50ed724f8abc0d814d9dd
python : 3.9.12.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 106 Stepping 6, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.1.3
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.17.2
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
</details>