<jupyter_start><jupyter_text>Seaborn practice<jupyter_code>import seaborn as sns
import pandas as pd
sns.get_dataset_names()
df=sns.load_dataset('titanic')
df.describe()
df.columns
df.sex.value_counts()
df['sex']=df['sex'].apply(lambda x: 1 if x=='male' else 0 )
df.sex.value_counts()
df.head()
df=df.drop('class',axis=1)
df.embark_town.value_counts()
df.embarked.value_counts()
df=df.drop('embark_town',axis=1)
df.alive.value_counts()
df.survived.value_counts()
df['alone']=df['alone'].apply(lambda x: 1 if x==True else 0 )
df.head()
df.deck.value_counts()
df['adult_male']=df['adult_male'].apply(lambda x: 1 if x==True else 0 )
df['embarked']=df['embarked'].apply(lambda x: 1 if x=='S' else( 2 if x=='C' else 3) )
df.embarked.value_counts()
df.who.value_counts()
df['who']=df['who'].apply(lambda x: 1 if x=='man' else( 2 if x=='woman' else 3) )
df.head()
df=df.drop('alive',axis=1)
d={'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'nan':8}
df['deck']=df['deck'].apply(lambda x: d[str(x)])
df.head()
import numpy as np
np.nan
df['deck'] = df['deck'].replace(np.nan, 0)
df.head()
y=df['survived']
x=df.drop('survived',axis=1)
sns.countplot(y)
y.value_counts()<jupyter_output><empty_output><jupyter_text>Violin Plot<jupyter_code>import matplotlib.pyplot as plt
data=x
data_std=(data-data.mean())/data.std()
data=pd.concat([y,data_std],axis=1)
data=pd.melt(data,id_vars='survived',var_name='features',value_name='value')
plt.figure(figsize=(10,10))
sns.violinplot(x='features',y='value',hue='survived',data=data,split=True,inner='quart')
plt.xticks(rotation=45)
sns.boxplot(x='features',y='value',hue='survived',data=data)
sns.jointplot(x.loc[:,'sex'],x.loc[:,'adult_male'],kind='regg')
sns.set(style='whitegrid',palette='muted')
data=x
data_std=(data-data.mean())/data.std()
data=pd.concat([y,data_std],axis=1)
data=pd.melt(data,id_vars='survived',var_name='features',value_name='value')
plt.figure(figsize=(10,10))
sns.swarmplot(x='features',y='value',hue='survived',data=data)
plt.xticks(rotation=45)
f,ax=plt.subplot(figsize=(10,10))
sns.headmap(x.corr(),annot=True,linewidth=0.5,fmt='0.1f',ax=ax)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23247058823529412, 'fraction_numerical': 0.02211764705882353, 'mean_word_length': 10.248677248677248, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '594981', 'license': 'MIT', 'n_tokens_mistral': 963, 'n_tokens_neox': 922, 'n_words': 112, 'path': 'Seaborn_excersie.ipynb', 'repo_name': 'bhargavyagnik/Seaborn-data-visualization', 'size': '2125'}