Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding max /min value of individual columns

I am a beginner to Data Analysis using Python and stuck on the following:

I want to find maximum value from individual columns (pandas.dataframe) using Broadcasting /Vectorization methodology.

A snapshot of my data Frame is as follows:enter image description here

like image 228
SeleCoder Avatar asked Oct 30 '17 00:10

SeleCoder


2 Answers

you can use pandas.DataFrame built-in function max and min to find it

example

df = pandas.DataFrame(randn(4,4))
df.max(axis=0) # will return max value of each column
df.max(axis=0)['AAL'] # column AAL's max
df.max(axis=1) # will return max value of each row

or another way just find that column you want and call max

df = pandas.DataFrame(randn(4,4))
df['AAL'].max()
df['AAP'].min()

min is the same

like image 103
陳耀融 Avatar answered Oct 11 '22 19:10

陳耀融


You can use aggregate function to get the min and max value in a single line of code.

For the entire dataset:

df.agg(['min', 'max'])

For a specific column:

df['column_name'].agg(['min', 'max'])

like image 2
Roy Avatar answered Oct 11 '22 19:10

Roy