title: Clustered standard errors in statsmodels with categorical variables (Python)
body: <p>I want to run a regression in statsmodels that uses categorical variables and clustered standard errors.</p>
  
  <p>I have a dataset with columns institution, treatment, year, and enrollment. Treatment is a dummy, institution is a string, and the others are numbers. I've made sure to drop any null values.</p>
  
  <pre><code>df.dropna()    
  reg_model = smf.ols("enroll ~ treatment + C(year) + C(institution)", df)
  .fit(cov_type='cluster', cov_kwds={'groups': df['institution']})
  </code></pre>
  
  <p>I'm getting the following:</p>
  
  <blockquote>
    <p>ValueError: The weights and list don't have the same length.</p>
  </blockquote>
  
  <p>Is there a way to fix this so my standard errors cluster?</p>