<jupyter_start><jupyter_text>Exploring Titanic Dataset Goals:* Make age distributions better/easier to work with for density plots Questions:* How can density plots be used to show some factors of surviving?<jupyter_code># Import magic
%matplotlib inline

# More imports
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

#Set general plot properties
sns.set_style("white")
# Load and show CSV data
titanic_data = pd.read_csv('titanic_data.csv')
# Get non-null ages
titanic_data = titanic_data[pd.notnull(titanic_data['Age'])]

# Round age to integer
titanic_data.loc[:, 'Age'] = titanic_data['Age'].apply(lambda x : int(x))

grouped = titanic_data.groupby('Sex')

# Female grouped
f_grouped = grouped.get_group('female')
f_first = f_grouped[f_grouped['Pclass'] == 1]
f_second = f_grouped[f_grouped['Pclass'] == 2]
f_third = f_grouped[f_grouped['Pclass'] == 3]

# Male grouped
m_grouped = grouped.get_group('male')
m_first = m_grouped[m_grouped['Pclass'] == 1]
m_second = m_grouped[m_grouped['Pclass'] == 2]
m_third = m_grouped[m_grouped['Pclass'] == 3]
fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, sharey=True)

sns.distplot(f[f['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax1)
sns.distplot(f[f['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax1)

sns.distplot(s[s['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax2)
sns.distplot(s[s['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax2)

sns.distplot(t[t['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax3)
sns.distplot(t[t['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax3)
fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, sharey=True)

sns.distplot(m_first[m_first['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax1)
sns.distplot(m_first[m_first['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax1)

sns.distplot(m_second[m_second['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax2)
sns.distplot(m_second[m_second['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax2)

sns.distplot(m_third[m_third['Survived'] == 1]['Age'], kde=False, bins=20, ax=ax3)
sns.distplot(m_third[m_third['Survived'] != 1]['Age'], kde=False, color='r', bins=20, ax=ax3)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19580731489741302, 'fraction_numerical': 0.027653880463871544, 'mean_word_length': 7.6937984496124034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '569248', 'license': 'MIT', 'n_tokens_mistral': 1005, 'n_tokens_neox': 918, 'n_words': 181, 'path': '2015-12-25-titanic-additional-grouping.ipynb', 'repo_name': 'GraysonR/titanic-data-analysis', 'size': '2242'}