python - 我正在尝试使用 plotly 创建一个热图,它会显示某种受 covid 影响的区域的动画,但它有一些问题
问题描述
所以下面是代码,我跑去获取我的热图。
问题是某些国家/地区并非每天都有更新的行,因此在其中一个国家出现行之前会有一些缺失的天数。这反映在 choropleth 地图中,它显示有病例的国家/地区,然后在没有任何数据的日子里将其删除。即使有些日子不见了,我也想保留第一次出现的亮点,但我觉得很难。
merg['Difference'] = np.where(merg.Country_Region == merg.Country_Region.shift(), merg.LastUpdate - merg.LastUpdate.shift(), np.nan)
我创建了一个名为差异的列,用于存储两行日期之间的差异:
fig = px.choropleth(maps, locations="iso_alpha",
color="Confirmed", # Confirmed is a column of confirmed cases of maps
hover_name="Country_Region", # column to add to hover information
animation_frame = "LastUpdate", #LastUpdate is the column of dates
color_continuous_scale=['#0d0887', '#46039f', '#7201a8', '#9c179e', '#bd3786', '#d8576b', '#ed7953', '#fb9f3a', '#fdca26', '#f0f921'])
fig.show()
解决方案
推荐阅读
- linux - su 和 sudo 未安装,但我需要 root 权限才能安装它们
- node.js - 无法通过带有 uglify-js 相关漏洞的 npm 审计
- java - 重命名 TableRow 属性名称
- r - 将单独文件中的 Stata 值标签读入 R
- java - Java 连接到 mySQL
- javascript - 当请求的凭据模式为“包含”时,响应中的“Access-Control-Allow-Origin”标头的值不能是通配符“*”
- r - R 函数不会按预期抛出错误
- f# - 这些从未更改(或仅在开始时更改一次)设置的模块属性?
- jquery - 打字稿模型到json - 忽略空值属性
- excel - 在 VBA 中使用字符串变量设置变量名