python - 在 pandas 中组合两个表格并将它们可视化为面积图
问题描述
嘿,我在 Pandas 中上传了以下数据:
Amerika = pd.read_csv("Amerika.csv")
Population = pd.read_excel("PopulationReport.xlsx")
Amerika 由以下列组成:Index(['state_name', 'overall_outcome', 'date', 'new_results_reported', 'total_results_reported'], dtype='object')
人口由以下列组成:Index(['state_name', 'Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3', 'Population_2019', 'Unnamed: 5'], dtype='object')
我的问题现在如下:
America 文件显示了我每天的所有数据。我想在这里仅用整体结果 = 'Positive' 和每个州的 new_results_reported 总数(state_name)来总结这些列。
我已经用一个透视图尝试过这个,然后它准确地显示了我想要的东西。问题是,我怎样才能将表 Population.Population_2019 中的列添加到另一个表中,以便我有一个显示在第 1 列中的表:state_name in column2: total number of new_results_reported='Positive' 和最后一列各州的人口数?
这是我的 pivot_chart 代码
pivot_df = Amerika.pivot_table(index='state_name', columns='overall_outcome', values='new_results_reported', aggfunc='sum')
打印(pivot_df)
最后,我想用数据 state_name、total_results_reported ='Positive' 直观地显示这个新表,并将其与 Population_2019 计数进行比较。
我希望有一个人可以帮助我
解决方案
推荐阅读
- vba - VBA, min/max ... 或其他数学函数
- git - Git合并处理删除的文件
- python - TensorFlow查找具有匹配值的像素
- android - 如何在 Android TV 上使用 Leak Canary
- mysql - MySQL“显示表状态”,自动增量不正确
- c# - 模拟 HttpMessageHandler 时未调用 SendAsync
- haskell - Haskell 中的“in”关键字有什么作用?
- amazon-web-services - RHEL 实例迁移(提升和转移)到 AWS
- linux - 如何在通过 apache 规则时查看 Web 请求
- regex - 正则表达式分析站点链接