题目
题目
单项选择题

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

选项
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)
查看解析

查看解析

标准答案
Please login to view
思路分析
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

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!