title: Calculating Moran's I with PySal?
body: <p>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'"</p>
  
  <p>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</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>The example script I am working from is located under "Moran" in this link:
  <a href="http://pysal.readthedocs.io/en/latest/users/tutorials/autocorrelation.html#moran-s-i" rel="nofollow noreferrer">http://pysal.readthedocs.io/en/latest/users/tutorials/autocorrelation.html#moran-s-i</a></p>