Skip to content
Advertisement

How to save the Pandas dataframe/series data as a figure?

It sounds somewhat weird, but I need to save the Pandas console output string to png pics. For example:

JavaScript

Is there any way like df.output_as_png(filename='df_data.png') to generate a pic file which just display above content inside?

Advertisement

Answer

Option-1: use matplotlib table functionality, with some additional styling:

JavaScript

enter image description here

Options-2 Use Plotly + kaleido

JavaScript

enter image description here

For the above, the font size can be changed using the font attribute:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement