Python字典到pandas数据框缺少关键值

问题描述 投票:0回答:1

我正在Windows 64上使用Python 3.8。

我使用PyPDF2查找字符串。我使用以下代码将这些值定义为字典:

keys=range(7)
values = (Docket, Date, CC, Owner, Scope, Crew, Additional)
dict_convert = dict(zip(keys,values))
print(dict_convert)

dict_convert打印在下面,并显示范围= 7(键0到6)

{0: '149623', 1: '21/10/19', 2: 'UTILITIES', 3: 'Camille .', 4: '008-lilyÞeld Rd-grove To Ryan-stop Slow-134-01, Rol_1268472_20190923-161408, ', 5: '5', 6: 'None'}

当我将其解析为Pandas DataFrame时,仅输出键0至4。有什么想法吗?预先感谢。

df = pd.DataFrame.from_dict(dict_convert, orient='index',dtype=None)
print(df.head())

0                                             153841
1                                           26/11/19
2                                 UTILITIES - 702008
3                                          Camille .
4  Rol_1300868_20191107-171403, 000-manning St-mo...
python pandas dataframe dictionary pypdf2
1个回答
1
投票

因为使用DataFrame.head会过滤前5行。

如果要查看小的DataFrame中的所有数据:

DataFrame.head

如果有更多行并添加了print(df)

...
© www.soinside.com 2019 - 2024. All rights reserved.