Home > Software engineering >  how to generate a graph in excel from data imported from python using python
how to generate a graph in excel from data imported from python using python

Time:05-08

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)`

CodePudding user response:

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

  • Related