I have a time series dataframe "his" with datetime index out of which I want to extract a certain range of timesteps. The starting point "selected_var_start" is in datetime index format (extracted from another dataframe). I want to extract in total 24 h.
I try do it like this: his = his.iloc[selected_var_start:(selected_var_start+pd.DateOffset(hours=24))]
I get the following error TypeError: cannot do positional indexing on DatetimeIndex with these indexers [DatetimeIndex(['2010-11-12 19:00:00'], dtype='datetime64[ns]', name='Datetime', freq=None)] of type DatetimeIndex
What am I doing wrong?
his = his.loc[selected_var_start:(selected_var_start+pd.DateOffset(hours=24))]
I get "pandas.errors.InvalidIndexError: DatetimeIndex(['2010-11-12 19:00:00'], dtype='datetime64[ns]', name='Datetime', freq=None)"