Ashu
Ashu

Reputation: 2266

Remove index column when exporting image using dataframe_image

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 ?

Upvotes: 3

Views: 1428

Answers (1)

user2246849
user2246849

Reputation: 4407

You can set the style to hide the index:

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

enter image description here

Upvotes: 2

Related Questions