The index in my DataFrame don't want to drop


I try to drop the index from my DataFrame but nothing works. From this DF I make report in HTML. I use style.set_table_styles() on this DF to change header colours, which is probably reason of my problem. Let’s say this is my DF:

   A   B   C
0  263 90  10,8
1  718 90  10,6
2  219 80  9,7
3  217 90  9,6

I want this DF to look like this:

A   B   C
263 90  10,8
718 90  10,6
219 80  9,7
217 90  9,6

And this is my part of my code:

DF = DF.reset_index=(drop=True)
colors = {'A': '#e6ffcc','B':'#406c13','C':'#b3e87d'}
StyleDF =
                'selector': f'th.col{i}',
                'props': [('background-color', color)]
            } for i, color in enumerate(

HTML = f'''
             <title>some title</title>
        <style type="text/css">
        some style format.........
        some text.........

I tried also:
DF = pd.read_csv("file.csv",index_col=False)
None of these methods works. I only want to say that my program generates a similar Data Frame where I don’t use `style.set_table_styles()’ and in this case, I don’t have this problem.

Asked By: mlodycezar



Style docs suggest .hide(axis="index") on the Styler object.

Answered By: creanion
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.