Skip to content

DOC: pd.Period and pd.period_range should document that they accept datetime, date and pd.Timestamp #53632

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

ABizzinotto
Copy link
Contributor

NOTE: This is a follow up to PR #53611 as I realised the issue was incompletely addressed there

@ABizzinotto
Copy link
Contributor Author

@mroeschke I opened this PR to follow up on #53611 in addressing #53038. I realised I didn't push one last commit to the previous PR and the additional accepted types were missing from the end parameter of period_range, I only added them to start. I had also added a note to freq on Period indicating it is required if value is None.

I didn't open a new issue since this still addresses the previous one, but let me know if this is not the right course of action. Thanks and sorry!

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your PR - just got a question

@@ -2663,6 +2663,7 @@ class Period(_Period):
One of pandas period strings or corresponding objects. Accepted
strings are listed in the
:ref:`offset alias section <timeseries.offset_aliases>` in the user docs.
If value is not already period-like, freq is required.
Copy link
Member

@MarcoGorelli MarcoGorelli Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this is true? e.g. here I don't specify freq

In [1]: pd.Period('2020-01')
Out[1]: Period('2020-01', 'M')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoGorelli thanks. Good point, it works with a string, it just errors if value is None or datetime. Changed the note to reflect that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - looks fine for None though?

In [3]: pd.Period(None)
Out[3]: NaT

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi - is this still active? if so, could you address this comment please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed this comment. I believe it should be all set now

@ABizzinotto ABizzinotto requested a review from MarcoGorelli June 13, 2023 16:58
@mroeschke mroeschke added Docs Period Period data type labels Jun 13, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ABizzinotto

@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Jun 23, 2023
@MarcoGorelli MarcoGorelli merged commit 39c69da into pandas-dev:main Jun 23, 2023
@ABizzinotto ABizzinotto deleted the follow-up-update-to-period-docs branch July 2, 2023 08:37
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…atetime, date and pd.Timestamp (pandas-dev#53632)

* Update docstrings for pandas.Period and period_range

* Fix Period docstring comment

* Fix Period value docstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: pd.Period and pd.period_range should document that they accept datetime, date and pd.Timestamp
3 participants