kirti purohit
kirti purohit

Reputation: 431

Count values in Pandas data Frame -Python

I have a data set as such enter image description here

For simplicity -Let's say I want to calculate the number of type of each manufacturer of the plane. enter image description here

I want the output as such-

BOEING-xxx
EMBRAER-xxx
MCDONNELL-XXX
:
:
:
so on 

How can I do this ? Please help me out with this.

Upvotes: 0

Views: 51

Answers (1)

Timbus Calin
Timbus Calin

Reputation: 14983

You can use dataframe['manufacturer'].value_counts() to get the result that you want;

However, note that you have NaNs in your column; so prior to applying the function above, use:

dataframe.dropna(subset=['manufacturer'],inplace=True)

Summing it up:

  1. dataframe.dropna(subset=['manufacturer'],inplace=True)
  2. dataframe['manufacturer'].value_counts()

Upvotes: 2

Related Questions