<jupyter_start><jupyter_text>Data Visualization  Some Data Visualization Library For Python:  *Matplotlib  *Pandas  *Seaborn  *ggplot  *Bokeh  *plot.ly<jupyter_code>import seaborn as sns
titanic = sns.load_dataset('titanic')
df=titanic.copy()
df
df.info()
df.dtypes
import pandas as pd
df.sex=pd.Categorical(df.sex) #you can covert object to category for variables.
df.dtypes
df.shape
df.columns
df.describe().T
df.isnull().values.any() #check if there is any non value - true or false
df.isnull().sum() #number of non value for each variable
df['age'].fillna(0,inplace=True)
df['age'].fillna(df.mean(),inplace=True)
df.isnull().sum()
categories_df=df.select_dtypes(include=["category"])
categories_df.sex.unique()
categories_df['sex'].value_counts()<jupyter_output><empty_output><jupyter_text>Barplot - for visualization to categorical variables.<jupyter_code>from pandas.api.types import CategoricalDtype
df.alive.head(10)
bar_alive=df['alive'].value_counts().plot.barh();
bar_alive.set_title('alive in titanic')
sns.barplot(x='alive',y=df.alive.index, hue='sex',data=df)<jupyter_output><empty_output><jupyter_text>Distplot - show distribution of numerical variables<jupyter_code>sns.distplot(df.age,kde=True) #kde is density option
(sns
 .FacetGrid(df,hue='alive',height=5)
 .map(sns.kdeplot,'age',shade=True)
 .add_legend()
)
sns.catplot(x='sex',y='age',hue='alive',kind='point',data=df)<jupyter_output><empty_output><jupyter_text>Boxplot - Numerical data visualization<jupyter_code>sns.boxplot(x=df['age'],orient='v')
df.dtypes
sns.boxplot(x='fare',y='alive',data=df)<jupyter_output><empty_output><jupyter_text>Violin Graph - density and box plot together<jupyter_code>sns.catplot(x='sex',y='age',hue='alive',kind='violin',data=df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.159682899207248, 'fraction_numerical': 0.0022650056625141564, 'mean_word_length': 8.926966292134832, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '644280', 'license': 'Apache-2.0', 'n_tokens_mistral': 694, 'n_tokens_neox': 678, 'n_words': 105, 'path': 'Notebooks/DataVisualization.ipynb', 'repo_name': 'mehmethalis/my-datascience-notes', 'size': '1766'}