I have a data frame like this:
df
Server CPU_Usage Memory Usage
Prod1 80 30
Prod2 70 10
Prod3 20 12
I need to apply Pandas Style to show % sign next to the numbers like below:
Server CPU_Usage Memory_Usage
Prod1 80% 30%
Prod2 70% 10%
Prod3 20% 12%
I tried this:
df_style=df.style.format({'CPU_Usage':'{:}%', {'Memory_Usage':'{:}%')
When do df_style, it shows up on Jupyter notebook. But when I write this to excel as below:
df_style.to_excel(r'report.xlsx', engine='openpyxl')
Percent sign (%) disappear from the excel file. Any ideas to force writing % next to the CPU_Usage and Memory_Usage in excel file?


Please try: