Task 1: Exploring and Visualizing the Iris Dataset using Python, pandas, matplotlib, and seaborn.
1. Import Required Libraries
import pandas as pd
import seaborn as sns
import [Link] as plt
2. Load the Iris Dataset
# Load directly from the seaborn
df = sns.load_dataset('iris')
3. Inspect the Dataset
# Display the shape of the dataset
print("Shape:", [Link])
# Display the column names
print("Columns:", [Link]())
# Show the first 5 rows
print([Link]())
Shape: (150, 5)
Columns: ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species']
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
4. Scatter Plot
[Link](data=df, x='sepal_length', y='sepal_width', hue='species')
[Link]('Sepal Length vs Sepal Width')
[Link]()
spark What can I help you build? add_circle send
5. Histogram
df['petal_length'].hist(bins=20, edgecolor='black')
[Link]('Distribution of Petal Length')
[Link]('Petal Length')
[Link]('Frequency')
[Link]()
I can also use seaborn for prettier output:
[Link](df['petal_length'], kde=True)
[Link]('Petal Length Distribution')
[Link]()
6. Box Plot
[Link](data=df, x='species', y='sepal_length')
[Link]('Sepal Length by Species')
[Link]()
Summary With this task, you will have:
Loaded and inspected a real dataset.
Created key visualizations:
Scatter plot to study relationships.
Histogram to see distributions.
Box plot to detect outliers and variation.