Skip to content

BUG: PeriodIndex to DatetimeIndex fail or have wrong/no frequency #58092

New issue

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

Open
2 of 3 tasks
benHeid opened this issue Mar 31, 2024 · 1 comment
Open
2 of 3 tasks

BUG: PeriodIndex to DatetimeIndex fail or have wrong/no frequency #58092

benHeid opened this issue Mar 31, 2024 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@benHeid
Copy link
Contributor

benHeid commented Mar 31, 2024

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

pd.period_range("2020", periods=2, freq="M").to_timestamp(to_offset("ME"))
# Outputs DatetimeIndex(['2020-01-31', '2020-02-29'], dtype='datetime64[ns]', freq=None)

pd.period_range("2020", periods=3, freq="M").to_timestamp(to_offset("ME"))
# Outputs DatetimeIndex(['2020-01-31', '2020-02-29', '2020-03-31'], dtype='datetime64[ns]', freq='ME') Wrong frequency

pd.period_range("2020", periods=2, freq="M").to_timestamp("ME") # Fails

pd.period_range("2020", periods=3, freq="M").to_timestamp("ME") # Fails

Issue Description

Related to #56213

Expected Behavior

All of these four lines should return a datetindex with 2ME as frequency.

I suppose that the the frequency term in to_timestamp is ignored and the frequency is directly inferred.

Installed Versions

INSTALLED VERSIONS

commit : bdc79c1
python : 3.10.13.final.0
python-bits : 64
OS : Darwin
OS-release : 23.2.0
Version : Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.1
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : 3.0.8
pytest : 7.4.0
hypothesis : None
sphinx : 7.2.6
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.21.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 : 2023.12.2
gcsfs : None
matplotlib : 3.8.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : 2.0.28
tables : None
tabulate : None
xarray : 2024.1.1
xlrd : None
zstandard : None
tzdata : 2023.4
qtpy : None
pyqt5 : None

@benHeid benHeid added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2024
@kvnwng11
Copy link

kvnwng11 commented Apr 2, 2024

take

@kvnwng11 kvnwng11 removed their assignment Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants