Say I have a series like the one below:
mySeries = pd.Series([1,2,3],['c','b','a'])
How do I go about getting the max value along with the name associated with it in a single line? In this case: a: 3
I can get the max value with: mySeries.max()
, the name of the max value with mySeries.idxmax(axis=1)
but I can't figure out how to get both of those values with one line. Suggestions?
pd.Series.nlargest
mySeries.nlargest(1)
a 3
dtype: int64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With