For an assignment at Uni we have to use PySal to calculate Moran's I. I have found an examplar code and am going from that but I am getting the error message "'file' object has no attribute 'by_col'"
Any Ideas would be much appreciated. The dataset is a text file of new york and the "T0_MINC" attribute is the column containing median household income for the different areas. The script is attached below
import os
import pysal
import numpy as np
os.chdir = ("C:\\Users\\hsv0336\\Desktop")
wd = os.getcwd()
w = pysal.open(wd + "\\Rook.gal")
f = pysal.open(wd + "\\NewYorkData.txt")
y = np.array(f.by_col["T0_MINC"])
mi = pysal.Moran(y, w, two_tailed=False)
The example script I am working from is located under "Moran" in this link: http://pysal.readthedocs.io/en/latest/users/tutorials/autocorrelation.html#moran-s-i