[In]
df.describe()
[Out]
count 48016
unique 40
top volkswagen
freq 10185
Name: brand, dtype: object
Here's what I've tried
df.value_counts().iloc[0,0]
That returned an error. I think it's because it is returns series and not a dataframe in which case, I cannot extract the top value, only the value count.
I then tried searching for the df.describe() parameters, but couldn't work with anything there.
Even foolishly tried df.describe().top() and df.describe(top) hoping either would work.
I feel like I'm missing something trivial here. How can I extract the top value ('volkswagen') in df.describe()?
As with any series, you can access a value by label via the dot notation or the square brackets __getitem__
notation.
In this case, it's simply df.describe().top
or df.describe()['top']
.