CLN: Consistency of arguments in to_html and to_string · Issue #23612 · pandas-dev/pandas (original) (raw)

The methods to_html and to_string share most of the parameters, together with DataFrameFormatter, but there are some differences in the order, and in some parameters that probably should be the same.

Those are the common parameters:

buf=None,
columns=None,
col_space=None,
header=True,
index=True,
na_rep='NaN',
formatters=None,
float_format=None,
sparsify=None,
index_names=True,
justify=None,
max_rows=None,
max_cols=None,
show_dimensions=False

But after formatters they are in different order, which adds complexity (for example in reusing docstrings, or in switching from one function to another when using positional arguments).

Then, those are the parameters that are not shared among the 3:

DataFrameFormatter
--
frame,  # (positional, at the beginning)
line_width=None,
decimal='.',
table_id=None,

to_string
--
line_width=None,

to_html
--
decimal='.',
table_id=None
bold_rows=True,
classes=None,
escape=True,
notebook=False,
border=None,

While that looks mostly ok, it feels like probably to_string should also have a decimal argument (and not sure what DataFrameFormatter should have.

What I propose is:

@jreback happy to make these changes?

CC @thoo