Skip to content

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

Merged
merged 7 commits into from
Mar 12, 2018

Conversation

Denniskamau
Copy link
Contributor

@Denniskamau Denniskamau commented Mar 10, 2018

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • [ x] PR title is "DOC: update the pandas.DatetimeIndex.to_period docstring"
  • [ x] The validation script passes: scripts/validate_docstrings.py pandas.DatetimeIndex.to_period
  • [ x] The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • [ x] The html version looks good: python doc/make.py --single pandas.DatetimeIndex.to_period
  • [ x] It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:


################################################################################
################## Docstring (pandas.DatetimeIndex.to_period) ##################
################################################################################

Cast to PeriodIndex at a particular frequency.

Converts DatetimeIndex to PeriodIndex.

Parameters
----------
freq : string or pandas offset object, optional
    One of pandas date offset string or corresponding objects.

Returns
-------
period : DatetimeIndex

Examples
--------
>>> df = pd.DataFrame({"y": [1,2,3]},
...                   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")
>>> df
            y
2000-03 1
2000-05 2
2000-08 3

See also
--------
pandas.PeriodIndex: Immutable ndarray holding ordinal values
pandas.DatetimeIndex.to_pydatetime: Return DatetimeIndex as object

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.DatetimeIndex.to_period" correct. :)

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.

Cast to PeriodIndex at a particular frequency
Cast to PeriodIndex at a particular frequency.

Converts timestamps index to period.
Copy link
Contributor

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.

Copy link
Contributor Author

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


Parameters
----------
freq : string or pandas offset object,optional
Copy link
Contributor

Choose a reason for hiding this comment

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

space before optional.

Parameters
----------
freq : string or pandas offset object,optional
One of pandas date offset string or corresponding objects.
Copy link
Contributor

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>`


Returns
-------
period: period[D]
Copy link
Contributor

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).

Examples
--------
>>> df = pd.DataFrame({"y": [1,2,3]},
... index=pd.to_datetime(["2000-03-31 00:00:00",
Copy link
Contributor

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 {.

... 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")
Copy link
Contributor

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.


See also
--------
Index: base pandas index type
Copy link
Contributor

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

@jreback jreback changed the title "DOC: update pandas.DatetimeIndex.to_period docstring(Nairobi) DOC: update pandas.DatetimeIndex.to_period docstring(Nairobi) Mar 10, 2018
Cast to PeriodIndex at a particular frequency
Cast to PeriodIndex at a particular frequency.

Converts DatetimeIndex to periodIndex.
Copy link
Contributor

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

@jreback jreback added Docs Period Period data type labels Mar 10, 2018
@pep8speaks
Copy link

pep8speaks commented Mar 10, 2018

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
Copy link

codecov bot commented Mar 11, 2018

Codecov Report

Merging #20131 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.11% <100%> (-0.01%) ⬇️
#single 41.84% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 95.64% <100%> (ø) ⬆️
pandas/core/base.py 96.78% <0%> (-0.02%) ⬇️
pandas/core/series.py 93.85% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.66% <0%> (-0.01%) ⬇️
pandas/core/indexes/multi.py 95.06% <0%> (ø) ⬆️
pandas/core/generic.py 95.84% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 840d432...fa32bcc. Read the comment docs.

Added reference to offsets.

Added Raises.

Added inferred example.
@TomAugspurger
Copy link
Contributor

Thanks @Denniskamau! I added an example with the frequency being inferred.

@TomAugspurger TomAugspurger merged commit 78ded25 into pandas-dev:master Mar 12, 2018
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.

4 participants