就在我以为我终于明白了的时候,真是个新手。
我正在尝试从 PDF 表格的一列中获取数字列表。
第一步我想转换为 Panda DF。
pip install tabula-py
pip install PyPDF2
import pandas as pd
import tabula
df = tabula.read_pdf('/content/Manifest.pdf')
然而,我得到的输出是一个 1 的列表,而不是 DF。当我查看 DF 时,信息就在那里,我只是不知道如何访问它,因为它是一个 1 的列表。
所以不知道为什么我没有得到 DF,也不知道我对 1 的列表意味着什么。Output https://i.stack.imgur.com/iDutl.png
不确定这是否重要,但我正在使用 google Colab。
任何帮助都是极好的。
Thanks
tabula.read_pdf 返回数据帧列表,无需任何其他参数。要访问您的特定数据框,您可以选择索引并使用它。
这是一个示例,我已阅读文档并选择第一个索引并比较类型
import tabula
df = tabula.read_pdf(
"https://github.com/chezou/tabula-py/raw/master/tests/resources/data.pdf")
df_0 = df[0]
print("type of df :", type(df))
print("type of df_0", type(df_0))
Returns:
type of df : <class 'list'>
type of df_0 <class 'pandas.core.frame.DataFrame'>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)