题目
单项选择题
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道考试原题与详细解析,现在登录,立即获得答案。
类似问题
Which one is the correct syntax to import library for data visualisation? You may choose one or more answers.
Why is visualizing the environment important in simulations, such as tracking the spread of radiation in a mouse habitat?
What role does the `getSymbol()` method play in the Environment class within a simulation?
Which Seaborn function is used to create a matrix of scatterplots for multiple variables, while also showing the distribution of each variable along the diagonal?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!