简体   繁体   English

Pysal 没有属性 open

[英]Pysal does not have attribute open

Hi I am using Anaconda with Python 3.7 and I have imported Pysal to my environment.嗨,我正在将 Anaconda 与 Python 3.7 一起使用,并且已将 Pysal 导入到我的环境中。 Now I am trying to import a dataset and open it with pysal, to my surprise it appears that pysal does not have attribute open...现在我正在尝试导入一个数据集并用 pysal 打开它,令我惊讶的是,pysal 似乎没有打开属性...

import pysal as ps
import libpysal as lps

lps.examples.explain('us_income')
csv_path = lps.examples.get_path('usjoin.csv')
f = ps.open(csv_path)

I am getting an error AttributeError: module 'pysal' has no attribute 'open'我收到一个错误AttributeError: module 'pysal' has no attribute 'open'

How can I fix it?我该如何解决?

The example dataset can be accessed using the modified script;可以使用修改后的脚本访问示例数据集;

# Import packages
import pysal as ps
import libpysal as lps
# Load example data 
lps.examples.explain('us_income')
csv_path = lps.examples.get_path('usjoin.csv')

# Note the difference here 
f = ps.lib.io.open(csv_path)

These changes are a result of PySAL migrating to 2.0 .这些变化是PySAL 迁移到 2.0的结果。 This assumes you are using PySAL >=2.0.这假设您使用的是 PySAL >=2.0。 Please mark this answer as correct if this answers your question.如果这回答了您的问题,请将此答案标记为正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM