pandas.DataFrame.at_time() Function with example
pandas.DataFrame.at_time() Fucntin : Select values at particular time of day (e.g. 9:30AM).
Syntax: DataFrame.at_time(time, asof=False, axis=None)
Parameters:
time : datetime.time or string
axis : {0 or ‘index’, 1 or ‘columns’}, default 0
New in version 0.24.0.
Returns:
values_at_time : same type as caller
Raises:
TypeError
If the index is not a DatetimeIndex
import pandas as pd
i = pd.date_range('2019-03-20', periods=4, freq='12H')
ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
print(ts)
print(ts.at_time('12:00'))
Output:
A 2019-03-20 00:00:00 1 2019-03-20 12:00:00 2 2019-03-21 00:00:00 3 2019-03-21 12:00:00 4 A 2019-03-20 12:00:00 2 2019-03-21 12:00:00 4