There are 3 column in a table. In column "Name" there are name and in column "No." there are no. with respect to column "Name" So here, I want to find which is a maximum no. of Jawed, Rahul, Vinay.
Below is the expected result.
CodePudding user response:
Use numpy.where with GroupBy.transform for compare max values by original column:
df['Max no.'] = np.where(df.groupby('Name')['No.'].transform('max').eq(df['No.']), 'Max','')
CodePudding user response:
We get the max_index of No. regarding the Name column :
max_value = df.Name[df['No.'].idxmax()]


