-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update pandas.DatetimeIndex.to_period docstring(Nairobi) #20131
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
DOC: update pandas.DatetimeIndex.to_period docstring(Nairobi) #20131
Conversation
pandas/core/indexes/datetimes.py
Outdated
Cast to PeriodIndex at a particular frequency | ||
Cast to PeriodIndex at a particular frequency. | ||
|
||
Converts timestamps index to period. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this? Oh, I think I see. How about Converts a DatetimeIndex to a PeriodIndex
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.I have made the changes.Thanks
pandas/core/indexes/datetimes.py
Outdated
|
||
Parameters | ||
---------- | ||
freq : string or pandas offset object,optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before optional
.
pandas/core/indexes/datetimes.py
Outdated
Parameters | ||
---------- | ||
freq : string or pandas offset object,optional | ||
One of pandas date offset string or corresponding objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include a link to the table of alias. Something like
:ref:`offset aliases <timeseries.offset_aliases>`
pandas/core/indexes/datetimes.py
Outdated
|
||
Returns | ||
------- | ||
period: period[D] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
period : DatetimeIndex
(need the space between the two).
pandas/core/indexes/datetimes.py
Outdated
Examples | ||
-------- | ||
>>> df = pd.DataFrame({"y": [1,2,3]}, | ||
... index=pd.to_datetime(["2000-03-31 00:00:00", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make 'index' right below the {
.
pandas/core/indexes/datetimes.py
Outdated
... index=pd.to_datetime(["2000-03-31 00:00:00", | ||
... "2000-05-31 00:00:00", | ||
... "2000-08-31 00:00:00"])) | ||
>>> df.index = df.index.to_period("M") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe just assign index = pd.to_datetime([...])
, no df
.
Then index.to_period("M")
and show the output.
pandas/core/indexes/datetimes.py
Outdated
|
||
See also | ||
-------- | ||
Index: base pandas index type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Index. Add pandas.PeriodIndex pandas.DatetimeIndex.to_pydatetime
pandas/core/indexes/datetimes.py
Outdated
Cast to PeriodIndex at a particular frequency | ||
Cast to PeriodIndex at a particular frequency. | ||
|
||
Converts DatetimeIndex to periodIndex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space, can you capitalize PeriodIndex
Hello @Denniskamau! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 12, 2018 at 16:17 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #20131 +/- ##
==========================================
- Coverage 91.72% 91.72% -0.01%
==========================================
Files 150 150
Lines 49156 49152 -4
==========================================
- Hits 45090 45086 -4
Misses 4066 4066
Continue to review full report at Codecov.
|
Added reference to offsets. Added Raises. Added inferred example.
Thanks @Denniskamau! I added an example with the frequency being inferred. |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py pandas.DatetimeIndex.to_period
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single pandas.DatetimeIndex.to_period
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.