Skip to content

DOC: Update the DatetimeIndex.normalize docstring #20094

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 3 commits into from
Mar 15, 2018

Conversation

techytushar
Copy link
Contributor

@techytushar techytushar commented Mar 10, 2018

Signed-off-by: Tushar Mittal chiragmittal.mittal@gmail.com

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

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • 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.normalize) ##################
################################################################################

Return DatetimeIndex with times converted to midnight.

When using DatetimeIndex, the time can be converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter.
Length is unaltered. The timezones are unaffected. If the frequency
is 'H','min' or 'S' it changes to None otherwise it remains 
unaffected.

Returns
-------
normalized : DatetimeIndex

See Also
--------
DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
DatetimeIndex.ceil : Ceil the DatetimeIndex to the specified freq.
DatetimeIndex.round : Round the DatetimeIndex to the specified freq.

Examples
--------
>>> df = pd.DatetimeIndex(start='2014-08-01 10:00', freq='H',
...                       periods=3, tz='Asia/Calcutta')
>>> df
DatetimeIndex(['2014-08-01 10:00:00+05:30',
               '2014-08-01 11:00:00+05:30',
               '2014-08-01 12:00:00+05:30'],
                dtype='datetime64[ns, Asia/Calcutta]', freq='H')
>>> df.normalize()
DatetimeIndex(['2014-08-01 00:00:00+05:30',
               '2014-08-01 00:00:00+05:30',
               '2014-08-01 00:00:00+05:30'],
               dtype='datetime64[ns, Asia/Calcutta]', freq=None)

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

Docstring for "pandas.DatetimeIndex.normalize" 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.

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

@techytushar techytushar changed the title Update the DatetimeIndex.normalize docstring Doc: Update the DatetimeIndex.normalize docstring Mar 10, 2018
Copy link
Contributor

@IHackPy IHackPy left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Mar 10, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@72eafde). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #20094   +/-   ##
=========================================
  Coverage          ?    91.7%           
=========================================
  Files             ?      150           
  Lines             ?    49152           
  Branches          ?        0           
=========================================
  Hits              ?    45074           
  Misses            ?     4078           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.08% <100%> (?)
#single 41.84% <100%> (?)
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 95.64% <100%> (ø)

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 72eafde...84aab8e. Read the comment docs.

@jreback jreback changed the title Doc: Update the DatetimeIndex.normalize docstring DOC: Update the DatetimeIndex.normalize docstring Mar 10, 2018
@jreback jreback added Docs Datetime Datetime data dtype labels Mar 10, 2018
Return DatetimeIndex with times converted to midnight.

When using DatetimeIndex, the time can be converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter in
Copy link
Contributor

Choose a reason for hiding this comment

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

This useful in cases where the time does not matter (remove the in DataFrame). The length of the DatetimeIndex is unaltered.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe mention this does not affect tz's

Examples
--------
>>> df = pd.DataFrame({'date':['2015-05-01 18:47:05.060000',
... '2014-05-01 18:47:05.110000']})
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add another example with a tz.

Return DatetimeIndex with times converted to midnight.

When using DatetimeIndex, the time can be converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter in
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe mention this does not affect tz's

@techytushar
Copy link
Contributor Author

@jreback required changes done, please review 😀

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small changes, otherwise lgtm.


When using DatetimeIndex, the time can be converted to midnight i.e.
00:00:00. This is useful in cases, when the time does not matter.
Length is unaltered. The timezones are unaffected. If the frequency
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the last sentence. freq is actually re-inferred here, so this is misleading.

@@ -1770,11 +1770,38 @@ def date(self):

def normalize(self):
"""
Return DatetimeIndex with times to midnight. Length is unaltered
Return DatetimeIndex with times converted to midnight.

Choose a reason for hiding this comment

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

Please, make a simpler description. I suggest Convert times to midnight.

Signed-off-by: Tushar Mittal <chiragmittal.mittal@gmail.com>
@techytushar
Copy link
Contributor Author

done!

@jreback jreback added this to the 0.23.0 milestone Mar 10, 2018
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good!

I made a few edits to make it more generic for both DatetimeIndex and Series.dt (they share the docstring)

@jorisvandenbossche jorisvandenbossche merged commit 6ccd6c1 into pandas-dev:master Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants