I have a dataframe as follows:
I want to have the max of the 'Sell_price' column according to 'Date' and 'Product_id' columns, without losting the dimension of dataframe as:
Since my data is very big, without a doubt using 'for' command is not logical.
CodePudding user response:
I think you are looking for transform
:
df['Sell_price'] = df.groupby(['Date', 'Product_id'])['Sell_price'].transform('max')