Reputation: 1144
I want to create a latex table from a pandas DataFrame, but column names are long, and I want to put them vertically, like this:
Currently I am using the to_latex
method, but I do not how to rotate the labels.
Upvotes: 5
Views: 1678
Reputation: 518
This should work by creating a new list based on the column names with the latex command to rotate by 90° and give this list as parameter for the headers:
df.to_latex(escape=False,header=['\\rotatebox{90}{' + c + '}' for c in df.columns]))
Upvotes: 7