pandas.DataFrame.at_time#

DataFrame.at_time(time, asof=False, axis=None)[源代码]#

选择一天中特定时间(例如上午9:30)的值。

参数
time日期时间.time或字符串
axis{0或‘index’,1或‘Columns’},默认为0
退货
系列或DataFrame
加薪
TypeError

如果索引不是 DatetimeIndex

参见

between_time

选择一天中特定时间之间的值。

first

根据日期偏移量选择时间序列的初始期间。

last

根据日期偏移量选择时间序列的最终期间。

DatetimeIndex.indexer_at_time

仅获取一天中特定时间的值的索引位置。

示例

>>> 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