The index in my DataFrame don't want to drop

Question:

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.sort_values(by=['B','C'],ascdening=[True,False],inplace=True)
DF = DF.reset_index=(drop=True)
colors = {'A': '#e6ffcc','B':'#406c13','C':'#b3e87d'}
StyleDF = DF.style.set_table_styles(
            [{
                'selector': f'th.col{i}',
                'props': [('background-color', color)]
            } for i, color in enumerate(DF.columns.map(colors))
            ])

HTML = f'''
        <html>
        <head>
             <title>some title</title>
        </head>
        <style type="text/css">
        some style format.........
        </style>
        <body>
        some text.........
        {StyleDF.to_html()}
        </body>
        </html>

I tried also:
Style.to_html(index=False)
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

||

Answers:

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.