I have big dataframe with datetime as index:
df =
vol element
2019-10-20 14:24:22 99499 8157_S1
2019-10-20 15:04:23 99500 8157_S2
2019-10-20 15:47:04 99501 8157_S1
2019-10-20 16:27:20 99502 8157_S2
2019-10-21 07:44:59 99503 8157_S1
2019-10-21 08:24:49 99504 8157_S2
2019-10-21 09:04:58 99505 8157_S2
I wanted to find the datetime index and value of vol
on a particular day for the particular element
item = '8157_S2' ### element I am searching for
day = '2019-10-21' ### date I am searching for
ses = 1 #### which session of the day I am searching for
vol = df['vol'][df['element'] == item].loc[day].iloc[ses]
dt_idx = df['vol'][df['element'] == item].loc[day].iloc[ses].index
Present output:
print(vol) >> 99505
print(dt_idx) >> AttributeError: 'list' object has no attribute 'loc'
Expected output:
print(vol) >> 99505
print(dt_idx) >> 2019-10-21 09:04:58
What could be wrong in my code in finding the index of a particular row among many satisfying rows?