Pandas DataFrame at_time() method with examples

Spread the love

The at_time() method helps us select values at particular time of day (e.g., 9:30AM).

Syntax –

DataFrame.at_time(time, asof=False, axis=None)

time – datetime.time or str

axis – {0 or ‘index’, 1 or ‘columns’}, default 0

Examples –

Let’s create a time series.

import pandas as pd

i = pd.date_range('2018-04-09', periods=4, freq='12H')
ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)

Let’s select all value at 12:00 PM


Rating: 1 out of 5.

Leave a Reply