Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to generate a graph in excel from data imported from python using python

I’m trying to generate a graph from the total variable. so x axis is month name is and y axis is total (expense).

total = 0
expenses = []
num_expenses =int(input("enter mumber of expenses: \n"))
for i in range(num_expenses):
   expenses.append(float(input("Enter an expense: \n")))

total = sum(expenses)

print("You spent £",total)`

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You’ll probably want to use Pandas for this. It comes with it’s own IO for different file types with some nice methods for excel stuff.

An example of making a chart on excel would be:

import pandas as pd

...

writer = pd.ExcelWriter('farm_data.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')

workbook = writer.book
worksheet = writer.sheets['Sheet1']

chart = workbook.add_chart({'type': 'column'})

...

Here’s somewhere to start.

https://pandas-xlsxwriter-charts.readthedocs.io/pandas.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading