python - 如何按类别绘制数据框列
问题描述
我有来自这里的数据集
我添加了另一个名称为摘要的列。
我正在尝试绘制 x=date 和 y=summary但每个国家/地区都有单独的行。
new_df = df["Country"].isin(["Germany","Canada","United Kingdom","US","France","China","India"])
new_df = df[new_df]
new_df = pd.DataFrame(new_df)
col_list = ['Confirmed','Recovered','Deaths']
new_df["Summary"] = new_df[col_list].sum(axis=1)
new_df['Date'] = pd.Series(pd.to_datetime(df['Date']))
print(new_df.tail())
Date Country Confirmed Recovered Deaths Summary
91811 2021-05-30 United Kingdom 4499937 15486 128043 4643466
91812 2021-05-31 United Kingdom 4503231 15507 128045 4646783
91813 2021-06-01 United Kingdom 4506333 15508 128045 4649886
91814 2021-06-02 United Kingdom 4510597 15514 128057 4654168
91815 2021-06-03 United Kingdom 4515778 15517 128075 4659370
我想绘制这样的图(每个国家的增长线在不同的线上)
解决方案
推荐阅读
- azure-devops - Azure DevOps 和 Teams - 一个组组来控制两者的成员资格
- python - 如何有效比较所有模型的准确性
- netlogo - 如何在带有另一个变量的补丁中计算具有某个变量的海龟?
- c# - 如何缩短到属性的路径?
- sql - sql oracle:当类型不存在时获取空值
- c# - 找不到非核心应用程序的模块“AspNetCoreModule”
- css - MacOS Chrome 水平滚动条没有消失
- java - Spring Security 和 Oauth2 的误区
- c# - 具体如果条件评估不正确
- dart - Flutter - 使用 package_info 在 iOS 中获取应用程序版本