After exploring and analyzing data with pandas I often create summarize tables (e.g. "table 1"). Currently I use pandas to create (layout) such tables and then export them to Excel via DataFrame.to_excel().

For example here you see in the first row the number of people and their mean age per group in the second row.

                GroupA   GroupB    Total
Total           959.00   764.00  1723.00
Age    Mean      73.34    73.55    73.43

Pandas dataframes are not suited to present data and offer layout options. I am aware of that. One problem for example is the Total row where the integers are converted to float64 because I added the mean values in the next row and they are float.

How do you generate "presentation tables" out of pandas data frames?


1 Answer 1


You can see the prettytable package. It has some simple API to convert dataframe into some good looking format.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.