Finding max /min value of individual columns

Question:

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

Asked By: SeleCoder

||

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

Answered By: 陳耀融

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'])

Answered By: Roy