diff --git a/docs/changelog.qmd b/docs/changelog.qmd index 130382016..d142efa64 100644 --- a/docs/changelog.qmd +++ b/docs/changelog.qmd @@ -20,6 +20,7 @@ fit3 = pf.feols("Y ~ X1 + X2 | f1", data = df) ### Bug Fixes - Fixes an import-time failure on Python 3.13 in some environments where a `narwhals` typing alias was exposed as a string at runtime. This could cause imports of `feols()` / `feglm()` to fail before any model code ran. See [#1263](https://github.com/py-econometrics/pyfixest/issues/1263) for details. +- Clarifies `pf.etable()` significance-star behavior after the migration to `maketables`: stars are rendered only when `coef_fmt` includes `*` on a statistic token, for example `b*` or `b:.3f*`. ## PyFixest 0.50.0 diff --git a/pyfixest/report/summarize.py b/pyfixest/report/summarize.py index dc1435593..6d1ffca51 100644 --- a/pyfixest/report/summarize.py +++ b/pyfixest/report/summarize.py @@ -71,11 +71,14 @@ def etable( Type of output. Either "df" for pandas DataFrame, "md" for markdown, "gt" for great_tables, or "tex" for LaTeX table. Default is "gt". signif_code : list, optional - Significance levels for the stars. Default is None, which sets [0.001, 0.01, 0.05]. - If None, no stars are printed. + Significance levels for the stars. Default is None, which sets + [0.001, 0.01, 0.05]. Note that stars are only rendered if `coef_fmt` + includes `*` on a statistic token, for example `b*` or `b:.3f*`. coef_fmt : str, optional The format of the coefficient (b), standard error (se), t-stats (t), and p-value (p). Default is `"b \n (se)"`. + To render significance stars, include `*` on the relevant token, following + maketables syntax, for example `"b* \n (se)"` or `"b:.3f* \n (se:.3f)"`. Spaces ` `, parentheses `()`, brackets `[]`, newlines `\n` are supported. custom_stats: dict, optional A dictionary of custom statistics that can be used in the coef_fmt string to be displayed diff --git a/tests/test_summarise.py b/tests/test_summarise.py index 4efc16b2a..555923e82 100644 --- a/tests/test_summarise.py +++ b/tests/test_summarise.py @@ -135,6 +135,18 @@ def test_summary(): etable(fit_qreg) +def test_etable_significance_stars_follow_coef_fmt(): + data = get_data() + fit1 = feols("Y ~ X1", data=data) + fit2 = feols("Y ~ X1 + X2 | f1", data=data) + + default_table = etable([fit1, fit2], type="df") + assert not any("*" in str(value) for value in default_table.to_numpy().ravel()) + + custom_fmt_table = etable([fit1, fit2], type="df", coef_fmt="b* (se)\nt [p]") + assert any("*" in str(value) for value in custom_fmt_table.to_numpy().ravel()) + + @pytest.mark.skip("Pyfixest PR is not yet merged into stargazer.") def test_stargazer(): data = pf.get_data()