0% found this document useful (0 votes)
27 views3 pages

9 Data Visualization

9_Data_Visualization

Uploaded by

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

9 Data Visualization

9_Data_Visualization

Uploaded by

harshalpatil96k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
In [2]: import seaborn as sb import matplotlib.pyplot as plt titanic = sb.load_dataset('titanic') ‘Assign 9- Jupyter Notebook titanic out [2]: survived pclass sex age sibsp parch fare embarked class. who _adult_ms ° 0 3 male 220 «1 «© 0 7.2600 S Third man tr 1 1 1 female 380 © 1 0 71.2833 © First woman Fal 2 1 3 female 260 0 0 7.9250 S Third woman Fal 3 1 1 female 350 1 0 $3,100 SFist woman Fal 4 0 3 male 350 «90 8.0500 S Thid man ™ 886 0 2 «male 270 ~=9 ~— 0 13.0000 S Second — man A 887 1 1 female 190 0 0 30.0000 S First woman Fal 888 0 3 female NaN 12 23.4500 S Third woman Fal 889 1 1 male 260 0 0 30.0000 © First man ™ 890 0 3 male 920 © «907.7500 Q Third man ™ 891 rows x 15 columns ——EEE » In [4]: sb.boxplot(data=titanic, x="sex’, y="age’, hue="survived') out[4]: locahost 8888inotebooks/DS LABIAssign @.ipyn 1 ‘Assign 9 -Jupyter Notebook In [5]: import pandas as pd # Download the Iris dataset from UCI Machine Learning Repository url = ‘https: //archive. ics.uci.edu/ml/machine-learning-databases/inis/iris.dat column_names = ['sepal length’, ‘sepal width’, ‘petal length’, ‘petal width’, inis_df = pd.read_csv(url, header=None, names=column_names) In [6]: # Print feature names and their types print(iris_df.dtypes) sepal length —floate4 sepal width —floate4 petal length —floatea petal width — floatea. class object dtype: object In [7]: import matplotlib.pyplot as plt # Create histograms for each feature iris_df.hist() # Set the title and axis Labels plt.suptitle( ‘Histograms of Iris Dataset Features’) plt.tight_layout(rect=[0, 0, 1, @.97]) # Adjust the subplot Layout plt.show() Histograms of Iris Dataset Features sepal length sepal width 20 2 2 o ° 5 6 7 8 2 3 ‘ petal length petal width cy n 2» ° ° 2 4 6 ° 1 2 locahost 8888inotebooks/DS LABIAssign @.ipyn 28 ‘Assign 9- Jupyter Notebook In [8]: # Create boxplots for each feature iris_df.plot (kind='box') # Set the title and axis Labels plt.title(‘Boxplots of Iris Dataset Features’) plt.ylabel(‘Value') plt.xticks(rotation=45) # Rotate x-axis Labels for better visibility plt.show() Boxplots of Iris Dataset Features In [ ]: locahost 8888inotebooks/DS LABIAssign @.ipyn 3

You might also like