Problem: Tables output by Pandas.DataFrame.to_latex() do not wrap long column headers. The line_width= parameter has been removed as of Pandas 0.24.
Discussion:
I'm exporting many tables with the df.to_latex() command, for inclusion in a master document. Many of the tables have wordy column headers, mostly owing to the need to include parenthesized units.
The end result is a set of absurdly sparse tables that often won't fit on the page.
Here's a sample of the too-sparse generated Tex:
\begin{tabular}{lrrrrrr}
\toprule
{} & Odometer (km/y) & Fuel (L/y) & Elec (kWh/y) & Economy (L/100km) & GHG (kg CO2e) & GHG (g/km) \\
Type & & & & & & \\
\midrule
Type 1 & 70753.62 & 9721.06 & 0.00 & 13.74 & 21386.33 & 302.26 \\
Type RRR & 56167.39 & 5285.40 & 1627.60 & 9.41 & 11642.54 & 207.28 \\
Type X & 195756.35 & 42957.04 & 0.00 & 21.94 & 94505.48 & 482.77 \\
Type Huh & 187384.66 & 18118.07 & 73.07 & 9.67 & 39860.40 & 212.72 \\
\bottomrule
\end{tabular}
Questions:
- Is there an alternate method of specifying wrapping in my generated .tex?
- Alternately, is there latex magic that will let my master latex document
\inputthese tables and specify a wrap width?
