<jupyter_start><jupyter_text>Learning Data Viz techniques from an online class<jupyter_code>df = pd.read_csv("titanic.csv")
df.head()
df["survived"].value_counts()
df.isnull().sum()
df.info()
sns.heatmap(df.isnull(), yticklabels=False, cbar= False, cmap ='viridis' )<jupyter_output><empty_output><jupyter_text>- Most of the missing is in the age, cabin, boat, body and home.dest column<jupyter_code>sns.countplot(x=df["survived"], hue= df["sex"], palette = "ocean")<jupyter_output><empty_output><jupyter_text>- We can observe that the more number of female have survived than males.- Also, among the deceased, there were more men than women.<jupyter_code>sns.countplot(x=df["survived"], hue= df["pclass"], palette = "inferno")
sns.displot(x = df["age"].dropna(), kde = False, bins =40)<jupyter_output><empty_output><jupyter_text>- We see that the age ranges from 0 to 80, with most of them belonging to the age group 20-50.- The maximum number of people belong to the age group of 25 to 30.<jupyter_code>df["age_category"] = pd.cut(
    df.age, 
    bins = [0,10,20,30,40,50,60,70,80], 
    labels = ["kids", "teenager", "young", "middle_aged", "upper middle", "old", "very_old", "senior"], ordered= True)
plt.figure(figsize = (25,8))
ax = sns.countplot(x=df["age_category"], data=df, hue= "survived", palette = "YlOrBr")<jupyter_output><empty_output><jupyter_text>- We observe that the majority of the people who did not survive are between the age group 20 to 30 followed by people in the age group 30-40. However, these are the counts and not percentages or proportions  Considering the proportions of people belonging to different age groups who survived<jupyter_code>temp_df = df.groupby("age_category")["survived"].sum().reset_index()
temp_df2 = df.groupby("age_category").size().reset_index()

final_temp = pd.merge(
    temp_df, 
    temp_df2, 
    on = "age_category",
    how= 'inner'
)
#final_temp['prop_survived'] = final_temp["survived"]/ final_temp[0]
#final_temp
#temp = df.groupby("survived")["age_category"].value_counts()
final_temp = final_temp.melt(id_vars = "age_category")
plt.figure(figsize =(12,8))
sns.barplot(data = final_temp, x="age_category",y="value", hue="variable")<jupyter_output><empty_output><jupyter_text>- This shows that maximum number of people in the ship belonged to the young catgeory and most of the people who survived alo belong to the same category, but the survived people do not account not even 50% of the total in that group.- More than half of the kids have survived. - Very few people belonging to the very_old category have survived.- Rest all categories approximately half of them were rescued.  Analyzing Fare<jupyter_code>sns.distplot(x = df["fare"].dropna(), kde = False, bins = 20)
temp_df_p_class = df.groupby("pclass")["survived"].sum().reset_index()
temp_p_class_total = df.groupby("pclass").size().reset_index()
final_temp_p_class = pd.merge(
    temp_df_p_class, 
    temp_p_class_total, 
    on = "pclass",
    how= 'inner'
)
final_temp_p_class
final_temp_p_class = final_temp_p_class.melt(id_vars = "pclass")
plt.figure(figsize =(12,8))
sns.barplot(data = final_temp_p_class, x="pclass",y="value", hue="variable")<jupyter_output><empty_output><jupyter_text>- We can observe that most of the people belonging to the class 1 have been recused- 50% of the people belonging to the class 2 have survived- Most of the people belonging to the class 3 have not been able to survive.  Age vs pclass<jupyter_code>plt.figure(figsize=(12,8))
sns.boxplot(x = "pclass", y="age", data = df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13025210084033614, 'fraction_numerical': 0.017366946778711485, 'mean_word_length': 5.9339805825242715, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '508832', 'license': 'MIT', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1200, 'n_words': 356, 'path': 'dataviz.ipynb', 'repo_name': 'valli180/titanic_data_analysis', 'size': '3570'}