Skip to content

Commit 5613547

Browse files
committed
Add docstring for DatetimeIndex.normalize method
Signed-off-by: Tushar Mittal <chiragmittal.mittal@gmail.com>
1 parent 731d971 commit 5613547

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,11 +1770,37 @@ def date(self):
17701770

17711771
def normalize(self):
17721772
"""
1773-
Return DatetimeIndex with times to midnight. Length is unaltered
1773+
Return DatetimeIndex with times converted to midnight.
1774+
1775+
When using DatetimeIndex, the time can be converted to midnight i.e.
1776+
00:00:00. This is useful in cases, when the time does not matter.
1777+
Length is unaltered. The timezones are unaffected. If the frequency
1778+
is 'H' it changes to None.
17741779
17751780
Returns
17761781
-------
17771782
normalized : DatetimeIndex
1783+
1784+
See Also
1785+
--------
1786+
DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
1787+
DatetimeIndex.ceil : Ceil the DatetimeIndex to the specified freq.
1788+
DatetimeIndex.round : Round the DatetimeIndex to the specified freq.
1789+
1790+
Examples
1791+
--------
1792+
>>> df = pd.DatetimeIndex(start='2014-08-01 10:00', freq='H',
1793+
... periods=3, tz='Europe/Berlin')
1794+
>>> df
1795+
DatetimeIndex(['2014-08-01 10:00:00+02:00',
1796+
'2014-08-01 11:00:00+02:00',
1797+
'2014-08-01 12:00:00+02:00'],
1798+
dtype='datetime64[ns, Europe/Berlin]', freq='H')
1799+
>>> df.normalize()
1800+
DatetimeIndex(['2014-08-01 00:00:00+02:00',
1801+
'2014-08-01 00:00:00+02:00',
1802+
'2014-08-01 00:00:00+02:00'],
1803+
dtype='datetime64[ns, Europe/Berlin]', freq=None)
17781804
"""
17791805
new_values = conversion.date_normalize(self.asi8, self.tz)
17801806
return DatetimeIndex(new_values, freq='infer', name=self.name,

0 commit comments

Comments
 (0)