To perform Exploratory Data Analysis on the given data set.
The primary aim with exploratory analysis is to examine the data for distribution, outliers and anomalies to direct specific testing of your hypothesis.
STEP 1: Import the required packages to perform Data Cleansing,Removing Outliers and Exploratory Data Analysis.
STEP 2: Replace the null value using any one of the method from mode,median and mean based on the dataset available.
STEP 3: Use boxplot method to analyze the outliers of the given dataset.
STEP 4: Remove the outliers using Inter Quantile Range method.
STEP 5: Use Countplot method to analyze in a graphical method for categorical data.
STEP 6: Use displot method to represent the univariate distribution of data.
STEP 7: Use cross tabulation method to quantitatively analyze the relationship between multiple variables.
STEP 8: Use heatmap method of representation to show relationships between two variables, one plotted on each axis.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df=pd.read_csv("/content/titanic_dataset.csv")
df
df.info()
![](https://private-user-images.githubusercontent.com/119104009/313682486-0c33d5af-14a9-4bd8-b86e-1a23becd4288.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjgyNDg2LTBjMzNkNWFmLTE0YTktNGJkOC1iODZlLTFhMjNiZWNkNDI4OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lYjFjNGExMDk3NGJjYTUyYWUzMDQyNGQ5YTQ1ZWZmNmI0ZDI5YzUzODg2OWVhYjcxMTIyYzViMzU4ZGJmMWUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.7Pg5c_fn3QIstn68KIrzl5OGQVegnCHygMgDnhnQ1-g)
df.shape
df.set_index("PassengerId",inplace=True)
print(df.set_index)
![](https://private-user-images.githubusercontent.com/119104009/313683289-62ef7c48-ef95-41cf-9ddb-3e0c0c83f2a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjgzMjg5LTYyZWY3YzQ4LWVmOTUtNDFjZi05ZGRiLTNlMGMwYzgzZjJhNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wYTA5ZDk4OTcxNzgwYmI3MzZlMzYzOTAzNzY3M2ZmOWE2YzIwNGJiYjJmODQ4ZGIzZDRmMTQ5MzE5NjFiMTNjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.AEnyBq97fS1pYaSTpdSpeeLWsL_SUpk6P7YCiUfQZcc)
df.nunique()
df["Survived"].value_counts()
sns.countplot(data=df,x="Survived",color="pink")
![](https://private-user-images.githubusercontent.com/119104009/313686858-374a8d82-d2a4-44e0-ad9b-110019f68c5d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjg2ODU4LTM3NGE4ZDgyLWQyYTQtNDRlMC1hZDliLTExMDAxOWY2OGM1ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lNTI2ODk0NWVlOGNhOWIzYmIwY2U5ZjIyODZhZmY2NzE0ZGVhMDE5N2RjNWJhYTM5ZGM1NmI5NmZkZDA4OTIyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.w-vohtHCpTfUH4982MRZX8XpMkdGizV-eMj-QmGoMUM)
df
df.Pclass.unique()
df.rename(columns={'sex':'Gender'},inplace=True)
df
![](https://private-user-images.githubusercontent.com/119104009/313687578-27303ebd-d00c-4764-8b77-3b87aa6e4a14.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjg3NTc4LTI3MzAzZWJkLWQwMGMtNDc2NC04Yjc3LTNiODdhYTZlNGExNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jOTBmMGNiMzhiNGE5NWY0MmQxZmE4NDAwMWE0MjM5Zjk5ZDMxMjIwYmI4Yjc3YWFmYmE2MmQ2ZDhjNzYyZDI0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.DPMIgARI-PZrRf97P93KCQXztRzJVyKqLo3e2tOfBks)
import seaborn as sns
df=pd.read_csv("/content/titanic_dataset.csv")
sns.catplot(x="Sex",col='Survived',kind="count",data=df,height=5, aspect=.7,color="pink")
![](https://private-user-images.githubusercontent.com/119104009/313688105-04b75a9f-ad61-4da9-aa95-9a9d61edccf0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjg4MTA1LTA0Yjc1YTlmLWFkNjEtNGRhOS1hYTk1LTlhOWQ2MWVkY2NmMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZDVjNGI1YTZkNjZiMGNlMGVlMjQzNjAwMjcwODIxOGI2YjQ1MzVjYmFkMDI5NTc4YmQ5ZDNkYjA1YjFmMjVmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.1Wth5x-3wIgAH6zn_P2Lrbd0Vzm9kqfas4uzvDiCero)
custom={"male":"cornflowerblue","female":"lavender"}
sns.catplot(x='Survived',hue='Sex',data=df,kind='count',palette=custom)
![](https://private-user-images.githubusercontent.com/119104009/313692930-44f1046e-6033-458d-86f7-d5dcb29f4c7f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjkyOTMwLTQ0ZjEwNDZlLTYwMzMtNDU4ZC04NmY3LWQ1ZGNiMjlmNGM3Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMzQ2YzI4MTBhOTUxOWJlYjM3ZDllYmEzZjljMDY4ODAyZjgzNjk2ZGRlODNmZmU5MWQwNWFkZjczMDI1MGQxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.OYR8h__iUt2ioNQAd6ubDp9qDuvwMmLygG-d6J2g30M)
df.boxplot(column='Age',by="Survived",color="red")
![](https://private-user-images.githubusercontent.com/119104009/313693685-c386b1b7-3b10-42d7-b461-fb111a831aac.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjkzNjg1LWMzODZiMWI3LTNiMTAtNDJkNy1iNDYxLWZiMTExYTgzMWFhYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNjExM2EzZmIwYWI2YjAxNjhiZGMwNjg1N2Y4ODQzN2MyMzljZTU2NGFlYzNlNjQyZTMyYTdjYmQ2Yjc2NTUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.t_QPJAjCDywBWPoUbBz0aK4fEq-zfHfp25PPjwm_V_g)
sns.scatterplot(x=df['Age'],y=df["Fare"],color="steelblue")
![](https://private-user-images.githubusercontent.com/119104009/313694331-69cf0d3a-e506-47bc-8007-a01c05154036.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjk0MzMxLTY5Y2YwZDNhLWU1MDYtNDdiYy04MDA3LWEwMWMwNTE1NDAzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZmNjNTFiZGE3ZTMxZjc5M2ZhNTM5MmI3NGYzOWViODI1ZTlhNTMwZDg4M2I5ZTA1OWIxNDEyYzNlOTVmOGZjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.HvVgKT-pLqIo72b3p-A75elJNJimWrrOlJiUdFgqYrA)
import matplotlib.pyplot as plt
fig,ax1=plt.subplots(figsize=(8,5))
pt=sns.boxplot(ax=ax1,x='Pclass',y='Age',hue='Sex',data=df,palette=custom)
![](https://private-user-images.githubusercontent.com/119104009/313694916-4df7b9c8-03f4-4b7b-a4c6-7e3f4708541a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjk0OTE2LTRkZjdiOWM4LTAzZjQtNGI3Yi1hNGM2LTdlM2Y0NzA4NTQxYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00MDVkNDA3YWI3NGEwYjdjMmMzMDdkNzA0NGIzY2IxZDM2ZGFmNDkxMWEyNThmNDYxZjlkNTAzN2UyZjRhYmI3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.oU8gXw7I5n-2itKk5X1q6lhuCskwggvQJdi5Izo3BZ4)
zenko={1:"skyblue",2:"cornflowerblue",3:"navy"}
sns.catplot(data=df,col='Survived',x='Sex',hue='Pclass',kind='count',palette=zenko)
![](https://private-user-images.githubusercontent.com/119104009/313697254-8076f5b2-6e8e-4646-9eaf-8d743f7921ce.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNjk3MjU0LTgwNzZmNWIyLTZlOGUtNDY0Ni05ZWFmLThkNzQzZjc5MjFjZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03MzI3MmIwNTdhMjZmZDBiNmNjNTg1OTI0MWFkYzczNTQ1NzdhMmQ3ZjAyYTE3MDUzN2I5ZmU5NTNmZDdmOWI4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.__HDkIXcyJNweD03O8qcn_6_-DzkU9CPALNccRqimQo)
import seaborn as sns
corr=df.corr()
sns.heatmap(corr,annot=True)
![](https://private-user-images.githubusercontent.com/119104009/313731095-6118e549-a04b-4882-88a8-e966dc5ac3a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNzMxMDk1LTYxMThlNTQ5LWEwNGItNDg4Mi04OGE4LWU5NjZkYzVhYzNhNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jODIyNDQ2YTAwNGU3NWYwN2RiYjYxOGVlMmZkYTBmYTQzNzYxZWExMDdkMDE0NDMxODRmZGJhOTI5Mjc0YjdlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Bkq4ZylWH7O5LFiuPm5z1neW2kxYMS_PeoyObEhTe8E)
sns.pairplot(df)
![](https://private-user-images.githubusercontent.com/119104009/313732583-46c54cb9-783e-4de2-b7ef-7be2b297c0d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMDU5NzgsIm5iZiI6MTcyNTIwNTY3OCwicGF0aCI6Ii8xMTkxMDQwMDkvMzEzNzMyNTgzLTQ2YzU0Y2I5LTc4M2UtNGRlMi1iN2VmLTdiZTJiMjk3YzBkOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQxNTQ3NThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMDEzZjcyNGI0ZjM1ZDEyMWRkODEyMGY4OTdiYmEzNjk3MTNmZjFmMmVkODcxNmFlMjFkZGMxNjU3NGUxZGQwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.yf7DQVugCMFXkygmIB7888WiU9BVX2hlzQuIJx4evzo)
Thus the Exploratory Data Analysis process is performed successfully on the given data using python code.