I have following data
group exog endog
A 1.2 0.23
A 1.3 0.34
A 1.4 0.45
B 1.5 0.56
B 1.6 0.67
B 1.7 0.78
C 1.8 0.89
C 1.9 1
C 2 1.11
like this:
def regression(df, exog, endog):
import statsmodels.api as sm
reg2 = sm.OLS(endog=df[exog],
exog=df[endog],
missing='drop')
results = reg2.fit()
df_ols_coefs = results.params.to_frame().T
df_ols_coefs.columns = [str(col) + '_coef' for col in df_ols.columns]
return df_ols_coefs
I thought about making "sub" dataframes from the original one, but I am stuck. Should I go for something like:
for df in df_orginal:
NOW I AM STUCK
? Explanation would really help me :D Thanks!