Questions
Questions
Single choice

import seaborn as sns Given a DataFrame df as shown above, how can you plot the bar chart as shown below?

Options
A.sns.barplot(y='date', x='gdp growth', data=df)
B.sns.barplot(x='date', y='gdp growth', data=df[df['date']<2020])
C.sns.barplot(x=df['date'], y=df['gdp growth'], data=df[df['date']<2020])
D.df.plot.bar(x=df['date'],y=df['gdp growth'],rot=0)
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
We’re asked to choose the correct way to plot a bar chart from a DataFrame df using seaborn, with the goal of matching the given example. Option 1: sns.barplot(y='date', x='gdp growth', data=df). Here the axes are swapped: y is assigned to 'date' and x to 'gdp growth'. In seaborn’s barplot, x should be the categorical axis (typically the variable to group by), and y should be the numeric measurement. If 'date' is a date-like or categorical label and 'gdp growth' is numeric, this......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for International Students

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!