How to Solve NameError: name 'ols' is not defined -- statsmodels
Solution: Import the 'ols' module
To Solve the error, add the following line to the top of your code.
from statsmodels.formula.api import ols
For more information:
Python statsmodels ols