assignment 9
assignment 9
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 [5]: sns.countplot(data['Survived'])
plt.show()
In [6]: data['Sex'].value_counts().plot(kind="pie", autopct="%.2f")
plt.show()
C:\Users\admin\AppData\Local\Temp\ipykernel_2836\3208151894.py:1: UserWarnin
g:
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:
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
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
Pclass
1 80 136
2 97 87
3 372 119