Python | Pandas Index.argmax()
Last Updated :
16 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Index.argmax()
function returns the indices of the maximum value present in the input Index. If we are having more than one maximum value (i.e. maximum value is present more than once) then it returns the index of the first occurrence of the maximum value.
Syntax: Index.argmax(axis=None)
Parameter: Doesn’t take any parameter.
Example #1: Use Index.argmax()
function to find the index of the maximum value present in the given Index.
import pandas as pd
df = pd.Index([ 17 , 69 , 33 , 5 , 0 , 74 , 0 ])
df
|
Output :
Let’s find the index of the maximum value present in our Index.
Output :
5
As we can see in the output, The maximum value in the Index is 74 and its index is 5 so the output is 5.
Example #2: Use Index.argmax()
function to find the index of the maximum value when we are having maximum value repeated more than once.
import pandas as pd
df = pd.Index([ 44 , 69 , 133 , 5 , 0 , 74 , 133 ])
df
|
Output :
Let’s find the index of the maximum value.
Output :
2
As we can see in the output, The Index.argmax()
function has returned the index of the first occurrence of the maximum value.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...