Description
Is your feature request related to a problem?
At present, table captions are always written above the table in the outputs. LaTeX will then render the caption above the table in the resulting document.
I prefer to put captions below tables (and figures) and would like the option to do so added to DataFrame.to_latex
.
Describe the solution you'd like
I propose adding a new argument to DataFrame.to_latex
, (say caption_position) with a default of 'above'
and valid values of 'above'
and 'below'
. One could equivalently use an Enum, but I'm not sure where that would live and don't think this idiomatic w.r.t. Pandas.
An alternative would be an argument caption_above with valid values of True
and False
.
I think the docstring would be something like
"""
Parameters
----------
caption_position : str, default 'above'
Position of the caption relative to the table. Acceptable values are `'above'` and `'below'`.
"""
API breaking implications
With a default, this should not change the API.
Describe alternatives you've considered
At present, I wait until I finally want to submit the document then manually change the files (where I put the output of DataFrame.to_latex
) manually. Without this feature, I would consider writing a function that takes the output of DataFrame.to_latex
and rearranges it.
Note
I'm happy to have a go at this — if it is not so trivial that someone can do it faster than saying OK — if people are happy with the proposed approach.