pandas.Series.dt.normalize#
- Series.dt.normalize(*args, **kwargs)[源代码]#
将时间转换为午夜。
将日期的时间部分设置为午夜,即 00:00:00。这在不需要时间的情况下很有用。长度保持不变。时区不受影响。
此方法可通过
.dt访问器在具有 datetime 值的 Series 上使用,也可直接在 Datetime Array/Index 上使用。- Returns:
- DatetimeArray、DatetimeIndex 或 Series
原始数据的同类型。Series 将具有相同的名称和索引。DatetimeIndex 将具有相同的名称。
Examples
>>> idx = pd.date_range(start='2014-08-01 10:00', freq='h', ... periods=3, tz='Asia/Calcutta') >>> idx 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') >>> idx.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)