I am trying to create a column chart using Pandas.
I have a DataFrame in the below format.
Week, Percent_Sold
1,13
2,15
3,44
I am trying to get a column chart using the below code:
chart = workbook.add_chart({'type': 'column'})
chart.add_series({'name': 'Sales Percent', 'categories': f'=\'sales\'!$A$11:$A$13',
'values': f'=\'sales\'!$B$11:$B$13',
'data_labels': {'value': True, 'num_format': '0%'}})
The above works well, however I see the numbers in chart get converted from 13 to 1300% but rather I am trying to display 13% in the chart. How could I modify the add_series
method to fix this.
If you want 13.00%
to be displayed:
'num_format':'0.00##\%'
Else if you want 13%
(without any decimals), then: 'num_format':'##\%'
Got answer from this topic: Percentage format multiplies cell value by 100
PS: It's more related to xlsxwriter than pandas