title: Can't access dataframe columns
body: <p>I'm importing a dataframe from a csv file, but cannot access some of it's columns by name. What's going on?</p>
  
  <p>In more concrete terms:</p>
  
  <pre><code>&gt; import pandas
  
  &gt; jobNames = pandas.read_csv("job_names.csv")
  &gt; print(jobNames)
  
     job_id   job_name   num_judgements
  0  933985        Foo              180
  1  933130        Moo              175
  2  933123        Goo              150
  3  933094       Flue              120
  4  933088        Tru              120
  </code></pre>
  
  <p>When I try to access the second column, I get an error:</p>
  
  <pre><code>&gt; jobNames.job_name
  </code></pre>
  
  <blockquote>
    <p>AttributeError: 'DataFrame' object has no attribute 'job_name'</p>
  </blockquote>
  
  <p>Strangely, I can access the job_id column thus:</p>
  
  <pre><code>&gt; print(jobNames.job_id)
  
  0    933985
  1    933130
  2    933123
  3    933094
  4    933088
  Name: job_id, dtype: int64
  </code></pre>
  
  <p><strong>Edit (to put the accepted answer in context):</strong></p>
  
  <p>It turns out that the first row of the csv file (with the column names) looks like this:</p>
  
  <pre><code>job_id, job_name, num_judgements
  </code></pre>
  
  <p>Note the spaces after each comma! Those spaces are retained in the column names:</p>
  
  <pre><code>&gt; jobNames.columns[1]
  
  ' job_name'
  </code></pre>
  
  <p>which don't form valid python identifiers, so those columns aren't available as dataframe attributes. I can still access them dict-style:</p>
  
  <pre><code>&gt; jobNames[' job_name']
  </code></pre>