Issue
I want to calculate the average temperature per day within an specific time frame, for example average temperature on the date = 2021-03-11 between time = 14:23:00 and 16:53:00. I tried with a pivot_table the following:
in_range_df = pd.pivot_table(df, values=['Air_temp'],
index=['Date','Time'],
aggfunc={'Air_temp':np.mean})
The dataframe looks like this:
But how can I specify the time range now? Any help is appreciated.
Solution
Usually you can use between
:
df[df["Datum"].between('2021-03-11 14:23:00',
'2021-03-11 16:53:00',)]["Air_temp"].mean()
Answered By - eshirvana
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.