Hello everyone, I'm new to this website and to prgramming in general. Taking a class and we're starting with python. Doin a programming project in which I need to do Data mining for a company. I'm stuck trying to get the company's monthly average for each month. I can A month's average but not every month with the year. Can anyone help me with wat I did wrong?
Here's the program I have so far:
def getDataList(fileName): dataFile = open(fileName, "r") dataList =  for line in dataFile: dataList.append(line.strip().split(',')) return dataList def getmonthavg(datalist): d= datalist monthlyaveragelist=  tv=0 vta=0 month= d[5:7] year= d[0:4] for i in d: v= float(i) c= float(i) if i[5:7] == month and i[0:4] == year: vtimesc= v*c tv= tv + v vta= vta + vtimesc ap= vta/tv aptuple= (ap,i[0:7]) monthlyaveragelist.append(aptuple) return monthlyaveragelist b = getDataList('table.csv') b.pop(0) c=getmonthavg(b) print c
Edited 6 Years Ago by flamedragon00: n/a