0% found this document useful (0 votes)
18 views7 pages

DSBDA9

The document outlines a data analysis process using the Titanic dataset, which includes various attributes such as survival status, passenger class, sex, age, and fare. It demonstrates data loading, checking for missing values, and visualizations using Seaborn, including joint plots, bar plots, box plots, and violin plots. The analysis focuses on the relationship between age, fare, and sex, with considerations for survival outcomes.

Uploaded by

naitikpawar22
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)
18 views7 pages

DSBDA9

The document outlines a data analysis process using the Titanic dataset, which includes various attributes such as survival status, passenger class, sex, age, and fare. It demonstrates data loading, checking for missing values, and visualizations using Seaborn, including joint plots, bar plots, box plots, and violin plots. The analysis focuses on the relationship between age, fare, and sex, with considerations for survival outcomes.

Uploaded by

naitikpawar22
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/ 7

In [1]: import pandas as pd

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

In [2]: dataset = pd.read_csv('C:/Users/prajw/Desktop/Indexs/DSBDA print/Assignment 9 (Data Visualization II)/titanic.csv')


dataset.head()

Out[2]: survived pclass sex age sibsp parch fare embarked class who adult_male deck embark_town alive alone

0 0 3 male 22.0 1 0 7.2500 S Third man True NaN Southampton no False

1 1 1 female 38.0 1 0 71.2833 C First woman False C Cherbourg yes False

2 1 3 female 26.0 0 0 7.9250 S Third woman False NaN Southampton yes True

3 1 1 female 35.0 1 0 53.1000 S First woman False C Southampton yes False

4 0 3 male 35.0 0 0 8.0500 S Third man True NaN Southampton no True

In [3]: dataset.shape

Out[3]: (891, 15)

In [4]: dataset.isnull()

Out[4]: survived pclass sex age sibsp parch fare embarked class who adult_male deck embark_town alive alone

0 False False False False False False False False False False False True False False False

1 False False False False False False False False False False False False False False False

2 False False False False False False False False False False False True False False False

3 False False False False False False False False False False False False False False False

4 False False False False False False False False False False False True False False False

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

886 False False False False False False False False False False False True False False False

887 False False False False False False False False False False False False False False False

888 False False False True False False False False False False False True False False False

889 False False False False False False False False False False False False False False False

890 False False False False False False False False False False False True False False False

891 rows × 15 columns

In [5]: dataset.isnull().sum()

Out[5]: survived 0
pclass 0
sex 0
age 177
sibsp 0
parch 0
fare 0
embarked 2
class 0
who 0
adult_male 0
deck 688
embark_town 2
alive 0
alone 0
dtype: int64

In [6]: dataset = dataset.dropna()

In [7]: sns.jointplot(x='age', y='fare', data=dataset)

Out[7]: <seaborn.axisgrid.JointGrid at 0x1f79bd2a690>


In [8]: sns.jointplot(x='age', y='fare', data=dataset, kind='hex')

Out[8]: <seaborn.axisgrid.JointGrid at 0x1f79a6406e0>

In [9]: sns.rugplot(dataset['fare'])

Out[9]: <Axes: xlabel='fare'>


In [10]: sns.barplot(x='sex', y='age', data=dataset)

Out[10]: <Axes: xlabel='sex', ylabel='age'>

In [ ]:

In [11]: import numpy as np


import matplotlib.pyplot as plt
import seaborn as sns

sns.barplot(x='sex', y='age', data=dataset, estimator=np.std)

Out[11]: <Axes: xlabel='sex', ylabel='age'>


In [12]: sns.countplot(x='sex', data=dataset)

Out[12]: <Axes: xlabel='sex', ylabel='count'>

In [13]: sns.boxplot(x='sex', y='age', data=dataset)

Out[13]: <Axes: xlabel='sex', ylabel='age'>

In [14]: sns.boxplot(x='sex', y='age', data=dataset, hue="survived")


Out[14]: <Axes: xlabel='sex', ylabel='age'>

In [15]: sns.violinplot(x='sex', y='age', data=dataset)

Out[15]: <Axes: xlabel='sex', ylabel='age'>

In [16]: sns.violinplot(x='sex', y='age', data=dataset, hue='survived')

Out[16]: <Axes: xlabel='sex', ylabel='age'>


In [17]: sns.stripplot(x='sex', y='age', data=dataset)

Out[17]: <Axes: xlabel='sex', ylabel='age'>

In [18]: sns.stripplot(x='sex', y='age', data=dataset, jitter=True)

Out[18]: <Axes: xlabel='sex', ylabel='age'>

In [19]: sns.stripplot(x='sex', y='age', data=dataset, jitter=True, hue='survived')

Out[19]: <Axes: xlabel='sex', ylabel='age'>


In [ ]:

You might also like