标签: python pandas dataframe matplotlib jupyter-notebook
我只想绘制 2 个国家/地区,以便比较两者之间的差异,但我不知道如何将其添加到我的代码中?
df.plot.bar(x='country'); // 它显示了所有的国家和它的值
我只想展示两个国家。
答案 0 :(得分:1)
您可以过滤这两个国家。假设这两个国家被称为 country a 和 country b:
country a
country b
mask = (df["Country"] == "country a") | (df["Country"] == "country b") df[mask].plot.bar(x="country")