Home > database >  Remove index column when exporting image using dataframe_image
Remove index column when exporting image using dataframe_image

Time:05-26

I am trying to export the data frame to an image. I used the dataframe_image lib to do this activity.

import pandas as pd
import dataframe_image as dfi

data = [
    {
        "name": "John",
        "gender": "Male"
    },
    {
        "name": "Martin",
        "gender": "Female"
    }
]

df = pd.json_normalize(data)
dfi.export(df, 'table.png')

The exported image looks like the below:

enter image description here

I want to remove the index column from this. How can I do that ?

CodePudding user response:

You can set the style to hide the index:

dfi.export(df.style.hide(axis='index'), 'table.png')

enter image description here

  • Related