0% found this document useful (0 votes)
11 views12 pages

assignment 9

The document outlines a Python assignment involving data analysis using the Titanic dataset and the tips dataset. It includes various data visualization techniques using libraries like Seaborn and Matplotlib, such as count plots, pie charts, histograms, and box plots. Additionally, it notes the deprecation of the 'distplot' function in Seaborn and suggests alternatives for future use.
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)
11 views12 pages

assignment 9

The document outlines a Python assignment involving data analysis using the Titanic dataset and the tips dataset. It includes various data visualization techniques using libraries like Seaborn and Matplotlib, such as count plots, pie charts, histograms, and box plots. Additionally, it notes the deprecation of the 'distplot' function in Seaborn and suggests alternatives for future use.
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
You are on page 1/ 12

ASSIGNMENT - 9

In [1]: import numpy as np


import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from seaborn import load_dataset

In [2]: data = pd.read_csv("titanic_Dataset.csv")

In [3]: data.head(3)

Out[3]: PassengerId Survived Pclass Name Sex Age SibSp Parch Tic

Braund,
0 1 0 3 Mr. Owen male 22.0 1 0
21
Harris

Cumings,
Mrs. John
Bradley
1 2 1 1 female 38.0 1 0 PC 17
(Florence
Briggs
Th...

Heikkinen,
STON/
2 3 1 3 Miss. female 26.0 0 0
3101
Laina

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

In [5]: sns.countplot(data['Survived'])
plt.show()
In [6]: data['Sex'].value_counts().plot(kind="pie", autopct="%.2f")
plt.show()

In [7]: plt.hist(data['Age'], bins=5)


plt.show()
In [9]: sns.displot(data['Age'])
plt.show()
In [11]: sns.distplot(data['Age'])
plt.show()

C:\Users\admin\AppData\Local\Temp\ipykernel_2836\3208151894.py:1: UserWarnin
g:

`distplot` is a deprecated function and will be removed in seaborn v0.14.0.

Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `histplot` (an axes-level function for histograms).

For a guide to updating your code to use the new functions, please see
https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751

sns.distplot(data['Age'])
In [12]: sns.scatterplot(x="total_bill", y="tip", hue="sex", data=tips)
plt.title("Scatter plot of Total Bill vs Tip")
plt.show()
In [13]: sns.barplot(x='Pclass', y='Age', hue='Sex', data=data)
plt.title("AverageAge by Class and Gender")
plt.show()
In [14]: sns.boxplot(x='Sex', y='Age', data=data)
plt.title("Age Distribution by Sex")
plt.show()
In [15]: sns.boxplot(x='Sex', y='Age', hue='Survived', data=data)
plt.title("Age distribution by Sex and Survival")
plt.show()
In [16]: sns.distplot(data[data['Survived'] == 0]['Age'], hist=False, color="blue")
sns.distplot(data[data['Survived'] == 1]['Age'], hist=False, color="orange")
plt.show()
C:\Users\admin\AppData\Local\Temp\ipykernel_2836\3376507986.py:1: UserWarnin
g:

`distplot` is a deprecated function and will be removed in seaborn v0.14.0.

Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `kdeplot` (an axes-level function for kernel density
plots).

For a guide to updating your code to use the new functions, please see
https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751

sns.distplot(data[data['Survived'] == 0]['Age'], hist=False, color="blue")


C:\Users\admin\AppData\Local\Temp\ipykernel_2836\3376507986.py:2: UserWarnin
g:

`distplot` is a deprecated function and will be removed in seaborn v0.14.0.

Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `kdeplot` (an axes-level function for kernel density
plots).

For a guide to updating your code to use the new functions, please see
https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751

sns.distplot(data[data['Survived'] == 1]['Age'], hist=False, color="orang


e")

In [17]: pd.crosstab(data['Pclass'], data['Survived'])


Out[17]: Survived 0 1

Pclass

1 80 136

2 97 87

3 372 119

In [18]: sns.heatmap(pd.crosstab(data['Pclass'], data['Survived']))

Out[18]: <Axes: xlabel='Survived', ylabel='Pclass'>

In [19]: sns.clustermap(pd.crosstab(data['Parch'], data['Survived']))


plt.show()
In [ ]:

This notebook was converted with convert.ploomber.io

You might also like