<jupyter_start><jupyter_text>Descriptive statistics 1<jupyter_code>import pandas as pd
columns = ['age', 'type_employer', 'fnlwgt', 'education',"education_num","marital", "occupation", "relationship", "race","gender","capital_gain", "capital_loss", "hr_per_week","country","income"]
df=pd.read_table("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",sep=',',names=columns,engine='python')
df.head()
df['gender'].value_counts()
df.shape
df.dtypes
counts = df.groupby('country').size()
counts
df.gender.unique
male_df=df.loc[df['gender']==' Male']
female_df=df.loc[df['gender']==' Female']
male_df
for column in df.columns:
  if df[column].dtypes == 'object':
    df[column] = df[column].apply(lambda x : x.strip())
mHI = df[(df.gender=='Male') & (df.income=='>50K')]
mHI
fHI = df[(df.gender==' Female')&(df.income==' >50K')]
fHI
df
df1 = df[(df.income==' >50K')]

print("Rate of ppl", int(len(df1)/float(len(df)) *100), '%' )
mHI['age'].mean()
male_df['age'].mean()
mv=mHI['age'].var()
fv =fHI['age'].var()
ms=male_df['age'].std()
fs =female_df['age'].std()
print(mv,fv,ms,fs)
import matplotlib.pyplot as plt
import seaborn as sns
sns.boxplot(male_df['age'])
mAge=male_df['age']
mAge.hist(histtype='bar', bins = 20)

plt.xlabel('Age', fontsize = 15)
plt.ylabel('Male Sample', fontsize = 15)
plt.show()
fAge=female_df['age']
fAge.hist(histtype='bar', bins = 20)

plt.xlabel('Age', fontsize = 15)
plt.ylabel('Female Sample', fontsize = 15)
plt.show()
mAge.hist(histtype='bar', bins = 10, alpha = 0.5, label='Male', color = sns.desaturate('indianred',0.75))
fAge.hist(histtype='bar', bins = 20, alpha = 0.5, label = 'Female')

plt.xlabel('Age', fontsize = 15)
plt.ylabel('Samples', fontsize = 15)
plt.legend()
plt.show()
mAge.hist(density = True, histtype='bar', bins = 10, alpha = 0.5, label='Male', color = sns.desaturate('indianred',0.75))
fAge.hist(density = True, histtype='bar', bins = 20, alpha = 0.5, label = 'Female')

plt.xlabel('Age', fontsize = 15)
plt.ylabel('Samples', fontsize = 15)
plt.legend()
plt.show()
mAge=male_df['age']
mAge.hist(histtype='step', bins = 20, linewidth = 3.5, density = True, cumulative = True)

plt.xlabel('Age', fontsize = 15)
plt.ylabel('CDF', fontsize = 15)
plt.show()
mAge.hist(density = True, histtype='step', cumulative=True,  bins = 10, alpha = 0.5, label='Male', color = sns.desaturate('indianred',0.75))
fAge.hist(density = True, histtype='step', cumulative=True,bins = 20, alpha = 0.5, label = 'Female')

plt.xlabel('Age', fontsize = 15)
plt.ylabel('Samples', fontsize = 15)
plt.legend()
plt.show()
 q= df.age.quantile([0.25,0.50, 0.75])
print(q)
df['age'].skew()
df['age'].kurtosis()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2223463687150838, 'fraction_numerical': 0.03202979515828678, 'mean_word_length': 6.481894150417827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '140552', 'license': 'MIT', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1046, 'n_words': 202, 'path': 'Descriptive_Statistics1.ipynb', 'repo_name': 'ColdCoffee21/Foundations-of-Data-Science', 'size': '2685'}