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

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

我使用python代码来分析我的数据。但是当我想阅读gal文件时,我收到了错误。

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

()1 ----> 2 w = pd.read(“C:\ Users \ Yousif \ Downloads \ PythonSpatial \ statess7.gal”)3中的AttributeError Traceback(最近一次调用)

AttributeError:模块'pandas'没有属性'read'

一旦我使用了这个功能

w = pysal.open(pysal.examples.get_path("statess7.gal")).read()

我收到了这个错误

KeyError Traceback(最近一次调用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返回os.path.join(base,'examples',example_name)34否则:---> 35引发KeyError(example_name +'在PySAL内置示例中找不到。')36 37

KeyError:'在PySAL内置示例中找不到statess7.gal。'

我希望了解如何从笔记本电脑中的路径读取和打开gal文件。

python pandas file gal
1个回答
0
投票

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

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

(大熊猫有.read_gal方法吗?我在官方文档中找不到它)

编辑:以上对我有用,但我必须设置编码以获得可读的数据帧,

df = pd.read_table("C:\path\file.gal", encoding="iso-8859-1")
© www.soinside.com 2019 - 2024. All rights reserved.