title: Why doesn't Statsmodels OLS support reading in columns with multiple words?
body: <p>I've been experimenting with Seaborn's lmplot() and Statsmodels .ols() functions for simple linear regression plots and their associated p-values, r-squared, etc. </p>
  
  <p>I've noticed that when I specify which columns I want to use for lmplot, I can specify a column even if it has multiple words for it:</p>
  
  <pre><code>import seaborn as sns
  import pandas as pd
  input_csv = pd.read_csv('./test.csv',index_col = 0,header = 0)
  input_csv
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AvD56.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AvD56.png" alt="CSV Plot"></a></p>
  
  <pre><code>sns.lmplot(x='Age',y='Count of Specific Strands',data = input_csv)
  &lt;seaborn.axisgrid.FacetGrid at 0x2800985b710&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9dBXN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9dBXN.png" alt="enter image description here"></a></p>
  
  <p>However, if I try to use ols, I'm getting an error for inputting in "Count of Specific Strands" as my dependent variable (I've only listed out the last couple of lines in the error):</p>
  
  <pre><code>import statsmodels.formula.api as smf
  test_results = smf.ols('Count of Specific Strands ~ Age',data = input_csv).fit()
  
  File "&lt;unknown&gt;", line 1
      Count of Specific Strands
             ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>Conversely, if I specify the "Counts of Specific Strand" as shown below, the regression works:</p>
  
  <pre><code>test_results = smf.ols('input_csv.iloc[:,1] ~ Age',data = input_csv).fit()
  test_results.summary()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qKgAN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qKgAN.png" alt="Regression Results"></a></p>
  
  <p>Does anyone know why this is? Is it just because of how Statsmodels was written? Is there an alternative to specify the dependent variable for regression analysis that doesn't involve iloc or loc?</p>