Skip to content

Commit 6ccd6c1

Browse files
techytusharjorisvandenbossche
authored andcommitted
DOC: Update the DatetimeIndex.normalize docstring (#20094)
1 parent 72eafde commit 6ccd6c1

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,11 +1964,41 @@ def date(self):
19641964

19651965
def normalize(self):
19661966
"""
1967-
Return DatetimeIndex with times to midnight. Length is unaltered
1967+
Convert times to midnight.
1968+
1969+
The time component of the date-timeise converted to midnight i.e.
1970+
00:00:00. This is useful in cases, when the time does not matter.
1971+
Length is unaltered. The timezones are unaffected.
1972+
1973+
This method is available on Series with datetime values under
1974+
the ``.dt`` accessor, and directly on DatetimeIndex.
19681975
19691976
Returns
19701977
-------
1971-
normalized : DatetimeIndex
1978+
DatetimeIndex or Series
1979+
The same type as the original data. Series will have the same
1980+
name and index. DatetimeIndex will have the same name.
1981+
1982+
See Also
1983+
--------
1984+
floor : Floor the datetimes to the specified freq.
1985+
ceil : Ceil the datetimes to the specified freq.
1986+
round : Round the datetimes to the specified freq.
1987+
1988+
Examples
1989+
--------
1990+
>>> idx = pd.DatetimeIndex(start='2014-08-01 10:00', freq='H',
1991+
... periods=3, tz='Asia/Calcutta')
1992+
>>> idx
1993+
DatetimeIndex(['2014-08-01 10:00:00+05:30',
1994+
'2014-08-01 11:00:00+05:30',
1995+
'2014-08-01 12:00:00+05:30'],
1996+
dtype='datetime64[ns, Asia/Calcutta]', freq='H')
1997+
>>> idx.normalize()
1998+
DatetimeIndex(['2014-08-01 00:00:00+05:30',
1999+
'2014-08-01 00:00:00+05:30',
2000+
'2014-08-01 00:00:00+05:30'],
2001+
dtype='datetime64[ns, Asia/Calcutta]', freq=None)
19722002
"""
19732003
new_values = conversion.date_normalize(self.asi8, self.tz)
19742004
return DatetimeIndex(new_values, freq='infer', name=self.name,

0 commit comments

Comments
 (0)