Closed

Description
to_string()
, to_html()
, to_latex()
, formatters
, float_format
, etc.
related #459
- The existing methods are not as flexible as users sometimes wish,
see Possible interactions with taldcroft/asciitable? #167, Float format syntax #2502, ENH: add escape parameter to to_html() #2919 (comment), Multilevel indexing with .to_latex() method merges two index columns #2942, Multilevel indexing with .to_latex() method merges two index columns #2924,HTMLFormatter.to_html() does not look at show_index_names #3195, Update DataFrame.to_latex() to have more flexibility #3196,ENH: update DataFrame to_latex for nicer typesetting #3264, BUG: adjust to_latex column format when no index #3467, Update DataFrame.to_latex() to have more flexibility #3197,ENH: Remove the hardcoded border=1 in the to_html dataframe export. #4578,API: Would it be useful for everyone if DataFrame.to_html (and to_string) had an argument to specify justify settings for each column? #4315, ml1., BUG: formatters argument to DataFrame.to_latex() is broken #6052 - Pandas' core competence is it's data structures and data ops DSL.
the output formats were added for convenience, but don't see much
ongoing work (formatting tables isn't sexy). - Users roll their own using custom code, there's no uniform way to do it
in a way that naturally extends pandas.
Template engines [jinja2, mako] are the accepted way of converting data into documents,
and the web dev community has provided great libraries to do it.
We should piggyback.
This would be good:
- Give users the power to scratch their own itch, avoiding the need for pandas devs
do it, or ignoring "fringe" use cases. - Provides users with a readable baseline , which is easy to modify and adapt to their needs.
- Having a standard way to do it (by customizing a template), users can more easily
have their output blend into python, and they can contribute / manage / source-control
document templates in a clean, self-contained way. - Escape the "%d" not "{:d}" silliness and format strings in general, which is a relic of
olden 2.5 support days. No more parameter hell necessary to make the existing methods
more expressive. I never ever want to format html tables using function arguments. - Use a better way to express formatting logic via a DSL, rather then piecing together
python strings. - Unify the handling of textual representations, not different code, only different template files.
- Can refactor this out of core (but not really, see below)
- Can provide features such as conditional formatting, styling.
However,
- Can't really remove existing methods.
- Adding a template engine dependency to pandas is clearly feature-creep (IMO).
So,
- Make it a standalone project out of core (or optional dependency?)
- Translate the existing styles into template form.
- Provide hooks in pandas to allow users to optionally install the
library and use it for rendeing - Let users know it's available for their use.