I have a dataframe df1
indexed by datetime with entries every minutes for weeks
sample:
SAMPLE_TIME Bottom Top Out state
0 2015-07-15 16:41:56 48.625 55.812 43.875 1
1 2015-07-15 16:42:55 48.750 55.812 43.875 1
2 2015-07-15 16:43:55 48.937 55.812 43.875 1
3 2015-07-15 16:44:56 49.125 55.812 43.812 1
4 2015-07-15 16:45:55 49.312 55.812 43.812 1
I want to find the day with the lowest Avg(TempBottom,TempTop), then get the entire day data by minute so i can plot that day, i tried:
df2 = df1.groupby(pd.TimeGrouper('D')).agg(min) \
.sort(['TempTop','TempBottom'], ascending=[True,True])
Which gives me the lowest temperature days ordered. sample:
SAMPLE_TIME Bottom Top Out state
2015-10-17 19.994 25.840 21.875 0
2015-08-29 26.182 28.777 25.937 0
2015-11-19 19.244 33.027 28.937 0
2015-11-07 19.744 33.527 28.125 0
then i though that all i need is to take the index of the first entry from df2:
df1[df2.index[1]]
But i am getting an error:
KeyError: Timestamp('2015-08-29 00:00:00')