【发布时间】:2021-11-28 06:10:16
【问题描述】:
在 Pandas 中,我有以下两个语句,它们都生成折线图。
df_merged.loc[df_merged['Country'] == 'The United Kingdom', ['DateReported', 'NewCases']].set_index('DateReported').plot.line(figsize=(10,6))
df_merged.loc[df_merged['Country'] == 'The United Kingdom', ['DateReported', 'DailyVaccinations']].set_index('DateReported').plot.line(figsize=(10,6))
两种说法是相同的。不同之处在于,在第一个中我使用“NewCases”,而在第二个中使用“DailyVaccinations”列
这就是 df_merged 的样子 有 21 列,但我只对绘制“NewCases”和“DailyVaccinations”感兴趣。
我想将这两个折线图合二为一。我该怎么做?
【问题讨论】:
-
请提供原始数据样本
-
如果您需要帮助将 DataFrame 的一个小样本格式化为 SO 的可复制代码,请参阅How to make good reproducible pandas examples。
标签: python pandas matplotlib