With .style.set_table_styles I can add borders to my df but when I write the df to excel file I see that it only keeps borders for header and index part. Borders of the data cells are disappearing. Here is the example code;
df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
df1.style.set_table_styles([
{"selector": "", "props": [("border", "1px solid black")]},
{'selector': 'tbody td','props': [('border', '1px solid black')]},
{"selector": "th", "props": [("border", "1px solid black")]}
]
, axis=1, overwrite=False)
df1.to_excel('df.xlsx')
Am I missing something or this is not manageable with pandas.style?