0

I ran the code below but it only worked when i only used columns that where one word

formula_string_indep_vars = ' + '.join(df_cars.drop(columns='Price').columns)
#formula_string = 'Price ~ ' + formula_string_indep_vars
formula_string = 'Price ~ ' + 'Levy + Manufacturer + Model + Category + Mileage + Cylinders + Doors + Wheel + Color + Airbags + Turbo'
print('formula_string: ', formula_string)

When i run the code below it doesnt work for column names which have 2 more words in the name e.g. "Gear box"

import statsmodels.api as sm

import statsmodels.formula.api as smf

import patsy

model_full = smf.glm(formula=formula_string, data=df_cars, family=sm.families.Binomial())

model_full_fitted = model_full.fit()

print(model_full_fitted.summary())
  • Does this answer your question? [Why doesn't Statsmodels OLS support reading in columns with multiple words?](https://stackoverflow.com/questions/52861445/why-doesnt-statsmodels-ols-support-reading-in-columns-with-multiple-words) – AlexK Oct 22 '22 at 07:57

0 Answers0