Pandas Excelwriter conditional formatting for percentage elements

Viewed 149

I have a data frame like this: -

enter image description here

Now, if I want to format any particular excel sheet for percentage, the whole column gets formatted according to percentage and changes all values to percentage.

Is there any way to first search for strings that ends with '%' and then convert only that particular string to percentage format so that it could be accepted by excel and not yield the green error box in excel. (I have tried conditional formatting and add_format method but it doesn't work)

Also, I am using pandas excelwriter for saving my dataframes into excel sheet, below is the code: -

Excelwriter = pd.ExcelWriter(Excel_File_Name,engine="xlsxwriter",engine_kwargs={'options': {'strings_to_numbers': True}})
0 Answers
Related