import pandas as pd

data = {
    '종속변인': [5, 10, 15, 20, 25, 30],
    '독립변인1': [1, 1, 2, 3, 3, 4, 5],
    '독립변인2': [25, 20, 15, 10, 5, 0],
    '독립변인3': [2, 4, 6, 8, 10, 12]
}

df = pd.DataFrame(data)
def significance(row):
    coef = row["coef"]
    p_value = row["P>|t|"]
    if p_value <= 0.001:
        return str(coef) + "***"
    elif p_value <= 0.01:
        return str(coef) + "**"
    elif p_value <= 0.05:
        return str(coef) + "*"
    else:
        return str(coef)
ols_ori = smf.ols('종속변인 ~ 독립변인1 + 독립변인2 + 독립변인3', data=df).fit()
ols_ori_summary = ols_ori.summary()

ols_ori_as_html = ols_ori_summary.tables[1].as_html()
ols_ori_pd = pd.read_html(ols_ori_as_html, header=0, index_col=0)[0]

ols_ori_pd["coef_with_star"] = ols_ori_pd.apply(significance, axis=1)
ols_ori_pd

업데이트: