Descriptive or Summary Statistics in python pandas – describe()

Descriptive or summary statistics in python – pandas, can be obtained by using describe function – describe(). Describe Function gives the mean, std and IQR values.

  • Generally describe() function excludes the character columns and gives summary statistics of numeric columns
  • We need to add a variable named include=’all’ to get the summary statistics or descriptive statistics of both numeric and character column.

Lets see with an example

Example of Descriptive or Summary Statistics in python

# creation of DataFrame

import pandas as pd
import numpy as np

#Create a Dictionary of series
d = {'Name':pd.Series(['Alisa','Bobby','Cathrine','Madonna','Rocky','Sebastian','Jaqluine',
   'Rahul','David','Andrew','Ajay','Teresa']),
   'Age':pd.Series([26,27,25,24,31,27,25,33,42,32,51,47]),
   'Score':pd.Series([89,87,67,55,47,72,76,79,44,92,99,69])}

#Create a DataFrame
df = pd.DataFrame(d)
print df

So the resultant DataFrame will be

Descriptive or Summary Statistics in python – pandas

 

 

Pandas- Descriptive or Summary Statistic of the numeric columns:

# summary statistics

print df.describe()

 

  • describe() Function gives the mean, std and IQR values. It excludes character column and calculate summary statistics only for numeric columns

so the output will be

Descriptive or Summary Statistics in python – pandas 1

 

 

Pandas – Descriptive or Summary Statistic of the character columns:

# summary statistics of character column

print df.describe(include=['object'])
  • describe() Function with an argument named include along with value object i.e include=’object’ gives the summary statistics of the character columns.

Descriptive or Summary Statistics in python – pandas 2

 

 

Pandas – Descriptive or Summary Statistic of all the columns

# summary statistics of character column

print df.describe(include='all')

describe() Function with include=’all’ gives the summary statistics of all the columns.

So the output will be

Descriptive or Summary Statistics in python – pandas 3

 

previous Descriptive or Summary Statistics in python 1                                                                                                                next Descriptive or Summary Statistics in python 2