for my thesis, I need a large dataframe as a LaTeX table.
It contains 126 rows and 5 columns.
I know, that there is a function df.to_latex(buf='citations.tex', largetable=True)
. However, when i run the function, it cuts of my strings in the columns!
I am using jupyter notebook. So when i print my dataframe there, the strings in the columns get abbreviated. This is all right. But when I use the to_latex()
function on my dataframe, the columns get abbreviated as well. Why is this happening?
My Dataframe:
title authors journal year doi
A visualization and modeling tool for security... Reijo M. Savola; Petri Heinonen 2011 Information Security for South Africa 2011 10.1109/ISSA.2011.6027518
Information security requirements – Interpreti... Mariana Gerber; Rossouw von Solms Computers & Security 2008 https://doi.org/10.1016/j.cose.2008.07.009
After using df.head(2).to_latex()
The LaTeX output:
'\\begin{tabular}{llllrl}\n\\toprule\n{} & title & authors & journal & year & doi \\\\\n\\midrule\n0 & A visualization and modeling tool for security... & Reijo M. Savola; Petri Heinonen & 2011 Information Security for South Africa & 2011 & 10.1109/ISSA.2011.6027518 \\\\\n1 & Information security requirements – Interpreti... & Mariana Gerber; Rossouw von Solms & Computers \\& Security & 2008 & https://doi.org/10.1016/j.cose.2008.07.009 \\\\\n\\bottomrule\n\\end{tabular}\n'
As you can see, the textoutput is not an output of the dataframe, but rather from the printed version. Even exporting to a file, doesn't help. df.to_latex('citations.tex', longtable=True)
is the command used, but it doesn't work as expected.
Why is this happening, and how to fix it?