Group A

Q9: Data Visualization II 1. Use the inbuilt dataset 'titanic' as used in the above problem. Plot a box plot for distribution of age with respect to each gender along with the information about whether they survived or not. (Column names : 'sex' and 'age') 2. Write observations on the inference from the above statistics.

Data Visualization II

Solution and implementation for Q9 from Data Science Laboratory (ds).

9_data_visualization_2.py Download
import seaborn as sns
import matplotlib.pyplot as plt

# Load dataset
df = sns.load_dataset("titanic")

# Boxplot
sns.boxplot(x="sex", y="age", hue="survived", data=df)

plt.title("Age Distribution by Gender and Survival")
plt.show()

Other Questions in Data Science Laboratory

See All Available Questions
Download