Skip to content

summary2() ignores float_format #1964

Closed

Description

@josef-pkt

reported on mailing list
https://groups.google.com/d/msg/pystatsmodels/VppPWg4G7rs/KDzfukbeID8J

specifying float_format doesn't have any effect
result_ols.summary2(float_format="%.8f")


In the actual table creation the format is hardcoded.

However, there might be other problems because settings has 3 dictionaries with conflicting values, and not all methods involved in the table creation might use the same settings.

Activity

  1. kiyoto commented on Aug 2, 2015

    @kiyoto
    Contributor

    @josef-pkt FWIW, I dug into this and here is what I am seeing:

    There are three settings because there are three subtables for OLS:

    1. The output of summary2.Summary.summary_model, which corresponds to the first setting but float_format is hard-coded in the code so there is nothing to be set.
    2. The output of summary2.Summary.summary_params, which corresponds to the second setting. This is what your commit referred to with settings[1].
    3. The output of diagnostics, which corresponds to the third setting but float_format is hard-coded again.

    I think there are two paths forward:

    1. Actually enable float_format in summary2 by making all three settings use the float_format that's passed into summary2.
    2. Deprecate float_format from summary2: since it has no effect anyway, this simply means updating docs, etc.
  2. josef-pkt commented on Aug 2, 2015

    @josef-pkt
    MemberAuthor

    @kiyoto Thanks for digging.

    I think solution 1.5 would work: to only enable the float_format in the params table. Both of the other tables have very heterogeneous numbers and I don't think it's very useful to change the numbers for those.

    Can the float_format for the params table be a list of format strings so users can adjust the print precision of the columns separately?

  3. kiyoto commented on Aug 2, 2015

    @kiyoto
    Contributor

    @josef-pkt

    I believe so. We can do something like,

    1. if float_format is passed in as a list, then it applies formatting per column.
    2. if float_format is passed in as a string, then it applies the same formatting to all columns.

    I can also imagine passing a python dict, but it's not all too clear what the field names should be.

    If this sounds like a plan, PR coming up.

  4. josef-pkt commented on Aug 2, 2015

    @josef-pkt
    MemberAuthor

    Sounds good.

    If you want to add the dict option additional to the list option, then it would be possible to use the names of the attributes (which IMO are nicer than the names that are printed as header of the params table, i..e. "pvalues" instead of "P>???"). Also, in that case I would use only one key in the dictionary for "confint" instead of separate formatting of lower and upper bound.

  5. added a commit that references this issue on May 8, 2019
  6. blincolm commented on Mar 25, 2024

    @blincolm

    Hi, I'm still having this problem. I have all new installs of pandas, statsmodels, and everything else (as of February 2024). Using summary2(float_format='%.3f') has no effect. Am I missing something? In fact, I can put any text, integers, or boolean value in the float_format parameter and it will return the same result.

    EDIT:
    Python 3.12.2
    statsmodels.version
    0.14.0
    pandas.version
    2.1.4
    numpy.version
    1.26.4

    ALSO TRIED (environment with):
    Python 3.9.13
    statsmodels.version
    0.13.5
    pandas.version
    1.4.4
    numpy.version
    1.23.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions