Reputation: 1
I used this code:
df_3 = df_2.groupby(df_2.index.strftime('%A %H:%M')).mean()
to create a dataframe that contains the mean of each timestamp for each weekday which looks like this:
date_col | Available |
---|---|
Friday 00:00 | 512.805556 |
Friday 00:05 | 515.184211 |
Friday 00:10 | 514.631579 |
Friday 00:15 | 517.477273 |
But I'm not sure how to locate one record based on the index. When I try with the displayed timestamp as a string, like df_3.iloc[['Friday 00:05']]
it throws an error but how would I refer to that value? date_col is the index
Upvotes: 0
Views: 224
Reputation: 4543
If your date is your index use loc
, iloc
is used to access by row number:
df_3.loc[['Friday 00:05']]
else, first set date_col
as index:
df_3.set_index('date_col')
also, you can access the row without setting the date_col
as index:
df_3[df_3['date_col']=='Friday 00:05']
Upvotes: 1