2

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?

ryszard eggink
  • 315
  • 3
  • 14

1 Answers1

1

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.

tastatham
  • 90
  • 1
  • 9
  • module 'pysal' has no attribute 'lib' – jlSta Aug 03 '21 at 09:17
  • Same result here: csv_path = lps.examples.get_path('usjoin.csv') # Note the difference here f = ps.lib.io.open(csv_path) Result: AttributeError: module 'pysal' has no attribute 'lib' – HM_ft Nov 16 '22 at 16:26
  • this was answered back in 2020, the API has changed since then :) – tastatham Mar 07 '23 at 17:52