Pysal does not have attribute open

2.4k Views Asked by At

Hi I am using Anaconda with Python 3.7 and I have imported Pysal to my environment. 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...

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'

How can I fix it?

1

There are 1 best solutions below

3
On

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. This assumes you are using PySAL >=2.0. Please mark this answer as correct if this answers your question.