如何从我的电脑中的选定路径读取和打开gal文件?

2024-05-16 07:01:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python代码分析数据。但是当我想读gal文件时,我出错了。在

w = pd.read_gal("C:\\Users\\Yousif\\Downloads\\PythonSpatial\\statess7.gal")

AttributeError Traceback (most recent call last) in () 1 ----> 2 w = pd.read("C:\Users\Yousif\Downloads\PythonSpatial\statess7.gal") 3

AttributeError: module 'pandas' has no attribute 'read'

我也曾经用过这个函数

^{pr2}$

我有这个错误

KeyError Traceback (most recent call last) in () 1 ----> 2 w = pysal.open(pysal.examples.get_path("statess7.gal")).read()

~\Anaconda3\lib\site-packages\pysal\examples__init__.py in get_path(example_name) 33 return os.path.join(base, 'examples', example_name) 34 else: ---> 35 raise KeyError(example_name + ' not found in PySAL built-in examples.') 36 37

KeyError: 'statess7.gal not found in PySAL built-in examples.'

我希望找到如何从我的笔记本电脑路径读取和打开gal文件。在


Tags: 文件pathnameinreadexampledownloadsexamples
1条回答
网友
1楼 · 发布于 2024-05-16 07:01:25

.gal是用制表符分隔的,所以可以尝试:

w = pd.read_table("C:\Users\Yousif\Downloads\PythonSpatial\statess7.gal")

(熊猫有没有^{cd1>}方法?我在官方文件里找不到)

编辑:上面的内容对我很有用,但是我必须设置编码来获得一个可读的数据帧

^{pr2}$

相关问题 更多 >