Get the maximum value of column in python pandas

Get the maximum value of column in python pandas : In this tutorial we will learn How to get the maximum value of all the columns in dataframe of python pandas. How to get the maximum value of a specific column in python pandas using max() function.  

Create Dataframe:


import pandas as pd
import numpy as np

#Create a DataFrame
d = {
'Name':['Alisa','Bobby','jodha','jack','raghu','Cathrine',
'Alisa','Bobby','kumar','Alisa','Alex','Cathrine'],
'Age':[26,24,23,22,23,24,26,24,22,23,24,24],

'Score':[85,63,55,74,31,77,85,63,42,62,89,77]}

df = pd.DataFrame(d,columns=['Name','Age','Score'])
df

So the resultant dataframe will be

Get the maximum value of column in dataframe –python pandas

 

Get the maximum value of all the column in python pandas:


# get the maximum values of all the column in dataframe

df.max()

This gives the list of all the column names and its maximum value, so the output will be

Get the maximum value of column in python pandas 1

 

Get the maximum value of a specific column in python pandas:

Example 1:


# get the maximum value of the column 'Age'

df['Age'].max()

This gives the maximum value of column Age so the output will be

26

 

Example 2:


# get the maximum value of the column 'Name'

df['Name'].max()

This gives the maximum value of column Name so the output will be

‘raghu’

 

 

 previous-small Get the maximum value of column in dataframe –python pandas                                                                                                               next_small Get the maximum value of column in dataframe –python pandas