Maximum value for different days

Viewed 23

I've got a datadrame with the following columns : Date / High price / Low price. About 300 trading days and the timeframe is hours. It's only for a single security.

I would like to find the code for the maximum high price for each different days. Maximum high price for day 1, Maximum high price for day 2...

I can't manage to find the solution.

Thank you

1 Answers

IIUC use DataFrameGroupBy.idxmax for indices by maximal High price per dates:

df1 = df.loc[df.groupby(df['Date'].dt.date)['High price'].idxmax()]

If need only dates with maximal prices:

df2 = df.groupby(df['Date'].dt.date)['High price'].max().reset_index()
Related