MCPcopy
hub / github.com/pandas-dev/pandas / normalize

Method normalize

pandas/core/arrays/datetimes.py:1154–1200  ·  view source on GitHub ↗

Convert times to midnight. The time component of the date-time is 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. This method is available on Series with datetim

(self)

Source from the content-addressed store, hash-verified

1152 return ints_to_pydatetime(self.asi8, tz=self.tz, reso=self._creso)
1153
1154 def normalize(self) -> Self:
1155 """
1156 Convert times to midnight.
1157
1158 The time component of the date-time is converted to midnight i.e.
1159 00:00:00. This is useful in cases, when the time does not matter.
1160 Length is unaltered. The timezones are unaffected.
1161
1162 This method is available on Series with datetime values under
1163 the ``.dt`` accessor, and directly on Datetime Array/Index.
1164
1165 Returns
1166 -------
1167 DatetimeArray, DatetimeIndex or Series
1168 The same type as the original data. Series will have the same
1169 name and index. DatetimeIndex will have the same name.
1170
1171 See Also
1172 --------
1173 floor : Floor the datetimes to the specified freq.
1174 ceil : Ceil the datetimes to the specified freq.
1175 round : Round the datetimes to the specified freq.
1176
1177 Examples
1178 --------
1179 >>> idx = pd.date_range(
1180 ... start="2014-08-01 10:00", freq="h", periods=3, tz="Asia/Calcutta"
1181 ... )
1182 >>> idx
1183 DatetimeIndex(['2014-08-01 10:00:00+05:30',
1184 '2014-08-01 11:00:00+05:30',
1185 '2014-08-01 12:00:00+05:30'],
1186 dtype='datetime64[us, Asia/Calcutta]', freq='h')
1187 >>> idx.normalize()
1188 DatetimeIndex(['2014-08-01 00:00:00+05:30',
1189 '2014-08-01 00:00:00+05:30',
1190 '2014-08-01 00:00:00+05:30'],
1191 dtype='datetime64[us, Asia/Calcutta]', freq=None)
1192 """
1193 new_values = normalize_i8_timestamps(self.asi8, self.tz, reso=self._creso)
1194 dt64_values = new_values.view(self._ndarray.dtype)
1195
1196 dta = type(self)._simple_new(dt64_values, dtype=dt64_values.dtype)
1197 dta = dta._with_freq("infer")
1198 if self.tz is not None:
1199 dta = dta.tz_localize(self.tz)
1200 return dta
1201
1202 def to_period(self, freq=None) -> PeriodArray:
1203 """

Callers 3

_add_offsetMethod · 0.45
_str_normalizeMethod · 0.45

Calls 4

viewMethod · 0.45
_simple_newMethod · 0.45
_with_freqMethod · 0.45
tz_localizeMethod · 0.45

Tested by

no test coverage detected