0

I need to extract my pandas dataframe as an image.

Input :

import pandas as pd 
data = [['tom', 10], ['nick', 15], ['juli', 14]] 
df = pd.DataFrame(data, columns = ['Name', 'Age']) 
df 

Output: Dataframe into png.

enter image description here

Thanks !!

Arvind Pant
  • 65
  • 1
  • 1
  • 8
  • https://stackoverflow.com/questions/35634238/how-to-save-a-pandas-dataframe-table-as-a-png – moys Sep 10 '19 at 03:29
  • Possible duplicate of [How to save a pandas DataFrame table as a png](https://stackoverflow.com/questions/35634238/how-to-save-a-pandas-dataframe-table-as-a-png) – Nitin Bisht Sep 10 '19 at 03:34

1 Answers1

0

Hi! test this:


import dataframe_image as dfi
import pandas as pd 
data = [['tom', 10], ['nick', 15], ['juli', 14]] 
df = pd.DataFrame(data, columns = ['Name', 'Age']) 
dfi.export(df, "mytable.png", table_conversion='matplotlib')

  • Welcome to StackOverflow Victor. While your code example may solve the question an explanation of how and why this solves the problem would really help to improve the quality of your answer. Remember that you're answering the question for readers in the future, not just the person asking now. I suggest you add an explanation to your answer. You might find the [How do I write a good answer](https://stackoverflow.com/help/how-to-answer) article helpful. – Mike Poole Jan 15 '21 at 16:10