The statsmodels workbench

Pyodide, preloaded np, pd, sm, plt, files, and privacy.

statsmodels is sm. Formulas live in statsmodels.formula.api as smf.

Goal

Print the version and a tiny OLS intercept.

import statsmodels.api as sm
print(sm.__version__)
import pandas as pd
import statsmodels.api as sm
df = pd.DataFrame({'x': [1, 2, 3], 'y': [2, 4, 5]})
print(sm.OLS(df['y'], sm.add_constant(df['x'])).fit().params.round(3).to_dict())