Recall & Review
beginner
What is a bar plot used for in data science?
A bar plot is used to show and compare the sizes or counts of different categories using rectangular bars. It helps us see which categories are bigger or smaller.
Click to reveal answer
beginner
How do you create a simple vertical bar plot using pandas?
Use the
plot.bar() method on a pandas DataFrame or Series. For example, data.plot.bar() will create a vertical bar plot.Click to reveal answer
beginner
What is the difference between
plot.bar() and plot.barh() in pandas?plot.bar() creates vertical bars, while plot.barh() creates horizontal bars. Use horizontal bars when category names are long or for better readability.Click to reveal answer
intermediate
How can you add labels to the x-axis and y-axis in a pandas bar plot?
After creating the plot, use
plt.xlabel('label') and plt.ylabel('label') from matplotlib to add axis labels.Click to reveal answer
intermediate
Why might you use stacked bar plots and how do you create them in pandas?
Stacked bar plots show parts of categories stacked on top of each other to compare totals and parts. Use
data.plot.bar(stacked=True) to create them.Click to reveal answer
Which pandas method creates a vertical bar plot?
✗ Incorrect
The method
plot.bar() creates vertical bar plots in pandas.What parameter makes a bar plot stacked in pandas?
✗ Incorrect
Use
stacked=True to create stacked bar plots in pandas.Which plot type is best when category names are long?
✗ Incorrect
Horizontal bar plots (
plot.barh()) are better for long category names.How do you add axis labels to a pandas bar plot?
✗ Incorrect
Axis labels are added with matplotlib functions
plt.xlabel() and plt.ylabel().What does a bar plot show?
✗ Incorrect
Bar plots compare sizes or counts of different categories.
Explain how to create and customize a basic bar plot using pandas.
Think about the pandas plotting method and matplotlib labels.
You got /4 concepts.
Describe when and why you would use a horizontal bar plot instead of a vertical one.
Consider label length and plot orientation.
You got /4 concepts.