How to Calculate Common Statistics in Pandas

Spread the love

In this post, you will learn How to calculate common statistics in pandas.

Read a Dataset –

import pandas as pd
url = "https://raw.githubusercontent.com/bprasad26/lwd/master/data/titanic.csv"
df = pd.read_csv(url)
df.head()

Mean –

df['Fare'].mean()
out - 32.204207968574636

Median –

df['Fare'].median()
out - 14.4542

SUM –

df['Fare'].sum()
out - 28693.9493

Maximum –

df['Fare'].max()
out - 512.3292

Minimum –

df['Fare'].min()
out - 0.0

Count –

df['Fare'].count()
out - 891

Variance –

df['Fare'].var()
out - 2469.436845743116

Standard deviation –

df['Fare'].std()
out - 49.6934285971809

Rating: 1 out of 5.

Leave a Reply