0

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

I am able to display the number with the formatting %. I am trying to add the % symbol next to the number, doing so changes the number from 13 to 1300%
it fails as it throws an error name 'f' is not defined

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.