Statsmodels Multiple Regression Syntax Error

I've been able to use the statsmodels.api regression when assigning variables to x and y, however, now I am trying to use the statsmodels.formula.api to to run a multiple regression that includes 1 categorical variable.  Unfortunately, I keep getting the following error: 

File "<unknown>, Line 1

C(Gender)

SyntaxError: invalid syntax

 

The code I am running that is causing the error is below:

model = smf.ols(formula= 'Age ~ C(Gender) + Height', data = df).fit()

 

Any help would be grateful

 

- J 

Please sign in to leave a comment.