Skip to content

Commit 3da2bdb

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

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,11 +1770,31 @@ 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 in
1777+
DataFrame. Length is unaltered.
17741778
17751779
Returns
17761780
-------
17771781
normalized : DatetimeIndex
1782+
1783+
See Also
1784+
--------
1785+
DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
1786+
DatetimeIndex.ceil : Ceil the DatetimeIndex to the specified freq.
1787+
DatetimeIndex.round : Round the DatetimeIndex to the specified freq.
1788+
1789+
Examples
1790+
--------
1791+
>>> df = pd.DataFrame({'date':['2015-05-01 18:47:05.060000',
1792+
... '2014-05-01 18:47:05.110000']})
1793+
>>> df.date = pd.to_datetime(df.date)
1794+
>>> df.date[1]
1795+
Timestamp('2014-05-01 18:47:05.110000')
1796+
>>> df.date[1].normalize()
1797+
Timestamp('2014-05-01 00:00:00')
17781798
"""
17791799
new_values = conversion.date_normalize(self.asi8, self.tz)
17801800
return DatetimeIndex(new_values, freq='infer', name=self.name,

0 commit comments

Comments
 (0)