22

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

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
SeleCoder
  • 233
  • 1
  • 2
  • 7

2 Answers2

26

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

陳耀融
  • 366
  • 3
  • 5
11

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

Roy
  • 924
  • 1
  • 6
  • 17