0% found this document useful (0 votes)
8 views6 pages

Data Visualization with Seaborn

The document contains a series of Python code snippets for data analysis and visualization using the Pandas and Seaborn libraries on the Titanic dataset. It includes various plots such as count plots, pie charts, histograms, scatter plots, bar plots, box plots, and heatmaps to explore relationships between variables like survival, age, sex, and class. The code also demonstrates data cleaning by dropping missing values before visualization.

Uploaded by

uldesoleha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Data Visualization with Seaborn

The document contains a series of Python code snippets for data analysis and visualization using the Pandas and Seaborn libraries on the Titanic dataset. It includes various plots such as count plots, pie charts, histograms, scatter plots, bar plots, box plots, and heatmaps to explore relationships between variables like survival, age, sex, and class. The code also demonstrates data cleaning by dropping missing values before visualization.

Uploaded by

uldesoleha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

4/9/25, 9:36 AM dsbda09

In [1]: import pandas as pd


import numpy as np
%matplotlib inline
import [Link] as plt
import seaborn as sns

In [2]: from seaborn import load_dataset


data = pd.read_csv("titanic_train.csv")

In [3]: tips = load_dataset("tips")

In [4]: [Link](data['Survived'])
[Link]()

In [5]: data['Sex'].value_counts().plot(kind="pie", autopct="%.2f")


[Link]()

In [6]: data = [Link]()

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 1/6


4/9/25, 9:36 AM dsbda09

In [7]: [Link](data['Age'],bins=5)
[Link]()

In [8]: [Link](data['Age'])
[Link]()

In [9]: [Link](tips["total_bill"], tips["tip"])

Out[9]: <[Link]._subplots.AxesSubplot at 0x7f90d4b3fb50>

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 2/6


4/9/25, 9:36 AM dsbda09

In [10]: [Link](tips["total_bill"], tips["tip"], hue=tips["sex"])


[Link]()

In [11]: [Link](tips["total_bill"], tips["tip"], hue=tips["sex"], style=tip


s['smoker'])
[Link]()

In [12]: [Link](data['Pclass'], data['Age'])


[Link]()

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 3/6


4/9/25, 9:36 AM dsbda09

In [13]: [Link](data['Pclass'], data['Fare'], hue = data["Sex"])


[Link]()

In [14]: [Link](data['Sex'], data["Age"])

Out[14]: <[Link]._subplots.AxesSubplot at 0x7f90d4a636d0>

In [16]: [Link](data['Sex'], data["Age"], data["Survived"])


[Link]()

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 4/6


4/9/25, 9:36 AM dsbda09

In [17]: [Link](data[data['Survived'] == 0]['Age'], hist=False, color="blue")


[Link](data[data['Survived'] == 1]['Age'], hist=False, color="orang
e")
[Link]()

In [18]: [Link](data['Pclass'], data['Survived'])

Out[18]:
Survived 0 1

Pclass

1 52 106

2 3 12

3 5 5

In [19]: [Link]([Link](data['Pclass'], data['Survived']))

Out[19]: <[Link]._subplots.AxesSubplot at 0x7f90d47b07d0>

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 5/6


4/9/25, 9:36 AM dsbda09

In [20]: [Link]([Link](data['Parch'], data['Survived']))


[Link]()

[Link] PRACTICALS/Sem 6/DSBDA/Sujal/[Link] 6/6

You might also like