Home > Mobile >  Get only the value of row with maximum count in Pandas
Get only the value of row with maximum count in Pandas

Time:09-27

I am trying to get the value of the row with maximum count value.

I created an output using q['Season'].value_counts().

I want only the first row value and not the count. e.g.:

Season Count
 2008    318
 2016    308
 2010    303

Output required: 2008

CodePudding user response:

You can convert value counts into dataframe and call idxmax function. This way -

q['Season'].value_counts().to_frame().idxmax()

Gives output -

Season    2008
dtype: int64

CodePudding user response:

q['Season'].value_counts().idxmax()

  • Related