Print OLS regression summary to text file

前端 未结 2 2098
Happy的楠姐
Happy的楠姐 2021-02-15 10:29

I am running OLS regression using pandas.stats.api.ols using a groupby with the following code:

from pandas.stats.api import ols
df=pd.         


        
2条回答
  •  梦谈多话
    2021-02-15 10:30

    In order to write out the result of pandas.stats.api.ols, use a text file to match the output format, for instance:

    from pandas.stats.api import ols
    grps = df.groupby(['FID'])
    for fid, grp in grps:
        result = ols(y=grp.loc[:, 'MEAN'], x=grp.loc[:, ['Accum_Prcp', 'Accum_HDD']])
    
        text_file = open("Output {}.txt".format(fid), "w")
        text_file.write(result.summary)
        text_file.close()
    

提交回复
热议问题