# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Variance  

# +
import pandas as pd

df = pd.read_csv('C:/Users/Swapnil/Desktop/Python Programs/InternShala - Data Science Python/Module - 3 - Statistics/Module 3 - Datasheets/Median.csv')
df
# -

df.head()



# # Calculate variance

# 1. Calculate mean.
# 2. Calculate the distance from mean for each element.
# 3. Calculate squared distance.
# 4. Take the average of the squared distance

# +
# 1. Mean 

mean = df['Overall Marks'].mean()
mean

# +
# 2. Calculate the distance from mean for each element

difference = df['Overall Marks'] - mean
difference

# +
# 3. Calculate squared distance

squared_dist = difference ** 2
squared_dist

# +
# 4.Take the average of the squared distance

variance = squared_dist.mean()
variance
# -



# # Using built in formula for variance

variance_formulae = df['Overall Marks'].var(ddof = 0)
print(variance_formulae)





# ## Mean, Mode & Median 

df['Overall Marks'].mean()

df['Overall Marks'].mode()

df['Overall Marks'].median()



# +
# Quiz question
# -

new_table = pd.DataFrame({'Count':[7, 6, 8, 4, 2, 7, 6, 7, 6, 5, 20]})
new_table

new_table['Count'].var(ddof = 0)

new_tabl = pd.DataFrame({'Count':[7, 6, 8, 4, 2, 7, 6, 7, 6, 5, 20]})
new_tabl

new_tabl['Count'].var(ddof = 0 )



StarcoderdataJupyterScriptsDedupFiltered