python - Pandas:将 dbf 表转换为数据框

标签 python pandas dataframe arcgis dbf

我想读取 ArcGIS shapefile 的 dbf 文件并将其转储到 pandas 数据框中。我目前正在使用 dbf包。

我显然已经能够将 dbf 文件作为表加载,但无法弄清楚如何解析它并将其转换为 pandas 数据帧。 有什么方法可以做到?

这是我被困在的地方:

import dbf
thisTable = dbf.Table('C:\\Users\\myfolder\\project\\myfile.dbf')
thisTable.open(mode='read-only')

Python 将此语句作为输出返回,坦率地说,我不知道该怎么做:

dbf.ver_2.Table('C:\\Users\\myfolder\\project\\myfile.dbf', status='read-only')


编辑

我的原始 dbf 示例:

FID   Shape    E              N
0     Point    90089.518711   -201738.245555
1     Point    93961.324059   -200676.766517
2     Point    97836.321204   -199614.270439
...   ...      ...            ...

最佳答案

你应该看看simpledbf :

In [2]: import pandas as pd

In [3]: from simpledbf import Dbf5

In [4]: dbf = Dbf5('test.dbf')

In [5]: df = dbf.to_dataframe()

这对我来说适用于一个小示例 .dbf 文件。希望对您有所帮助。

关于python - Pandas:将 dbf 表转换为数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41898561/

相关文章:

python - 如何将嵌套字典转换为数据框?

r - 根据多行中的值过滤 R 中的行

python - 如何获取 QTreeWidget 中被单击的项目?

python 检查列表元素的存在

python - 使用步幅填充 numpy 滚动窗口操作

pandas - 将带有计算的列添加到多个 CSV

python - 如何根据内容从 numpy 数组中提取行?

python - 如何根据 Pandas DataFrame 中其他列的值仅对列的某些元素求和?

python - Pandas ._libs.hashtable.PyObjectHashTable.get_item KeyError : 0

python - 如果 pandas df 中缺少行,则创建行