Skip to content

Instantly share code, notes, and snippets.

@theyesils
Created May 25, 2020 17:58
Show Gist options
  • Save theyesils/7fad6ce8d28f594f77b3f1ce6de579ad to your computer and use it in GitHub Desktop.
Save theyesils/7fad6ce8d28f594f77b3f1ce6de579ad to your computer and use it in GitHub Desktop.
#import the libraries we need
import numpy as np
import pandas as pd
from scipy import stats
#download the dataset
data=pd.read_csv("mafs.csv")
data.info()
#select the age variable using iloc[] function
age=data.iloc[:,4:5].values
type(data.iloc[:,4:5].values)
#mean
np.mean(age)
#median
np.median(age)
#mode
mode=stats.mode(age)
print('mode is :',mode[0])
#quartiles
np.percentile(age,[25,50,75])
#converting numpy to DataFrame
ages=pd.DataFrame(age)
#describe function for summary of central tendency
ages.describe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment