Skip to content

DOC: add section Raises to PeriodIndex docstring #57461

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

Merged

Conversation

natmokval
Copy link
Contributor

@natmokval natmokval commented Feb 16, 2024

we raise a ValueError: "freq not specified and cannot be inferred" if both freq and dtype are not specified in PeriodIndex

>>> pd.PeriodIndex(["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01"], freq="M")
PeriodIndex(['2023-01', '2023-02', '2023-03', '2023-04'], dtype='period[M]')

>>> pd.PeriodIndex(["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01"], dtype ="period[M]")
PeriodIndex(['2023-01', '2023-02', '2023-03', '2023-04'], dtype='period[M]')

>>> pd.PeriodIndex(["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01"])
ValueError: freq not specified and cannot be inferred

I added a section "Raises" to PeriodIndex documentation.

@natmokval natmokval marked this pull request as ready for review February 16, 2024 20:48
@natmokval natmokval added the Docs label Feb 16, 2024
@mroeschke mroeschke added this to the 3.0 milestone Feb 16, 2024
@mroeschke mroeschke merged commit c5bf3d3 into pandas-dev:main Feb 16, 2024
@mroeschke
Copy link
Member

Thanks @natmokval

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants