0
0
Pandasdata~5 mins

Bar plots in Pandas - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aplot.bar()
Bplot.barh()
Cplot.line()
Dplot.scatter()
What parameter makes a bar plot stacked in pandas?
Astack=True
Borientation='horizontal'
Ckind='stacked'
Dstacked=True
Which plot type is best when category names are long?
AHorizontal bar plot
BVertical bar plot
CLine plot
DPie chart
How do you add axis labels to a pandas bar plot?
AUsing <code>data.label()</code>
BUsing <code>plt.xlabel()</code> and <code>plt.ylabel()</code>
CUsing <code>data.axis_labels()</code>
DUsing <code>plot.labels()</code>
What does a bar plot show?
ARelationship between two continuous variables
BDistribution of a single continuous variable
CComparison of sizes or counts of categories
DTrend over time
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.