pandas.DataFrame.at_time#
- DataFrame.at_time(time, asof=False, axis=None)[源代码]#
选择一天中特定时间的(例如,上午 9:30)值。
- Parameters:
- timedatetime.time 或 str
要选择的值。
- axis{0 或 ‘index’, 1 或 ‘columns’}, default 0
对于 Series,此参数未使用,默认为 0。
- Returns:
- Series 或 DataFrame
- Raises:
- TypeError
如果索引不是
DatetimeIndex
参见
between_time选择一天中特定时间之间的值。
first根据日期偏移量选择时间序列的初始周期。
last根据日期偏移量选择时间序列的最终周期。
DatetimeIndex.indexer_at_time仅获取一天中特定时间的值的索引位置。
Examples
>>> i = pd.date_range('2018-04-09', periods=4, freq='12h') >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i) >>> ts A 2018-04-09 00:00:00 1 2018-04-09 12:00:00 2 2018-04-10 00:00:00 3 2018-04-10 12:00:00 4
>>> ts.at_time('12:00') A 2018-04-09 12:00:00 2 2018-04-10 12:00:00 4