matplotlib - 将 Webscraped 数据绘制到 matplotlib 上
问题描述
我最近设法使用 python 中的 camelot 从 PDF 文件中收集表格数据。通过收集我的意思是在终端上打印出来,现在我想找到一种方法将结果自动转换为 matplotlib 上的条形图。我该怎么做?这是我从pdf中提取表格数据的代码:
import camelot
tables = camelot.read_pdf("data_table.pdf", pages='2')
print(tables[0].df)
这是表格的 图像 在此处输入图像描述
然后在我的终端中打印出一张大表:
0 1 2 3 4
0 Country \nCase definition \nCumulative cases \...
1 Guinea Confirmed 2727 156 1683
2 Probable 374 * 374
3 Suspected 7 * ‡
4 Total 3108 156 2057
5 Liberia** Confirmed 3149 11 ‡
6 Probable 1876 * ‡
7 Suspected 3982 * ‡
8 Total 9007 11 3900
9 Sierra Leone Confirmed 8212 230 3042
10 Probable 287 * 208
11 Suspected 2604 * 158
12 Total 11103 230 3408
13 Total 23 218 397 9365
我确实对 matplotlib 有一些经验,并且我知道如何手动绘制数据,但不能从 pdf 中自动绘制数据。这会节省我一些时间,因为我正在尝试自动化整个过程。
解决方案
推荐阅读
- nim-lang - 如何在 nim 中构造“select ... in” SQL 查询?
- django - 使用 Django ORM 在 postgres 中获取索引信息
- c++ - 将数组传递给 C++ 中的函数并打印数组长度
- amazon-web-services - 极光 serverless 就算不使用也要花钱吗?
- makefile - 音频场景激活失败:1 [Makefile:68: run] 错误 1
- onesignal - OneSignal - 在线向特定用户发送通知 - 离线
- amazon-web-services - 抑制 AWS CDK 输出到标准输出
- laravel - 无法使用宅基地连接到数据库
- python - python / mysql:从多个表中选择覆盖结果字典中的重复列
- python - 打开一个文件,其名称存储在 python 的变量中