Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 950
Ashu Avatar asked Dec 05 '25 10:12

Ashu


1 Answers

You can set the style to hide the index:

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

enter image description here

like image 158
user2246849 Avatar answered Dec 08 '25 02:12

user2246849



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!