Lesson 3: Data Visualization
Data Visualization with Pandas
In this lesson, we'll explore:
- Basic plotting with Pandas
- Different types of plots
- Customizing visualizations
Concepts
Concept 3.1: Basic Plotting
Basic Plotting with Pandas
Pandas integrates with Matplotlib to provide easy plotting capabilities. Common plot types include:
- Line plots
- Bar plots
- Histograms
- Scatter plots
Code Sample
import pandas as pd
# Create sample data
df = pd.DataFrame({
'year': [2019, 2020, 2021, 2022],
'sales': [100, 120, 140, 180]
})
# Create a line plot
df.plot(x='year', y='sales')
# Create a bar plot
df.plot.bar(x='year', y='sales')