pandas :将dbf表转换为数据框 [英] Pandas: transform a dbf Table into a dataframe

查看:166
本文介绍了 pandas :将dbf表转换为数据框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to read a dbf file of an ArcGIS shapefile and dump it into a pandas dataframe. I am currently using the dbf package.

我显然已经能够将dbf文件作为表格加载,但是无法弄清楚如何解析它并将其转换为pandas数据框. 这是怎么做的?

I have apparently been able to load the dbf file as a Table, but have not been able to figure out how to parse it and turn it into a pandas dataframe. What is the way to do it?

这就是我所困的地方:

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

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

Python returns this statement as output, which I frankly don't know what to make of:

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文件.希望有帮助.

This works for me with a little sample .dbf file. Hope that helps.

这篇关于 pandas :将dbf表转换为数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆