I wrote the following piece of code but I just cannot get the 'predict' method to work:
import statsmodels.api as sm
from statsmodels.formula.api import ols
ols_model = ols('Consumption ~ Disposable_Income', df).fit()
My 'df' is a pandas dataframe with column headings 'Consumption' and 'Disposable_Income'. When I run, for example,
ols_model.predict([1000.0])
I get: "TypeError: list indices must be integers, not str"
When I run, for example,
ols_model.predict(df['Disposable_Income'].values)
I get: "IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices"
I'm very confused because I thought these two formats are precisely what the documentation says - put in an array of values for the x variable. How exactly am I supposed to use the 'predict' method?

~is different operator in pandas from R.