This the link for the steps to do it. https://docs.google.com/document/d/1O8B0MHZMKz04XFudUQA1c7dAAnkh2fj7/edit ?usp=sharing&ouid=1 XXXXXXXXXX&rtpof=true&sd=true This is the link for the csv file:...

1 answer below »
I am not getting desired result . i have coded half of the program but not able to move further. I have uploaded a file conating two links.1. steps to do it2. contains CSV file.i also have added my code too make chnages in it or u can do it ut way too.


This the link for the steps to do it. https://docs.google.com/document/d/1O8B0MHZMKz04XFudUQA1c7dAAnkh2fj7/edit ?usp=sharing&ouid=107807152497512387787&rtpof=true&sd=true This is the link for the csv file: https://drive.google.com/file/d/1WLz3nDx- O8FD2UBNmP0ZIGaM3tjlvgKN/view?usp=sharing The first file contains the output that is required with the steps to do it and below is the code which i did to plot a graph using matplotlib. If possible can anyone continue with the changes in below code, otherwise you can do it your way. I am not able to get the output, please anyone help. import csv from datetime import datetime import matplotlib.pyplot as plt import matplotlib.ticker as mtick data = [] csv_file = open('produce_extra.csv', 'r') reader = csv.reader(csv_file) for row in reader: # ! main loop reads one row at a time if reader.line_num == 1: # ! get the location names from row 1 locations = row[2:] # ! slice to remove commodity and date else: for location, value in zip(locations, row[2:]): # ! iterate through locations and values row_num = len(data) # ! index for the data row data.append(row[:2]) # ! new data row: commodity and date data[row_num].append(location) # ! append location date = datetime.strptime(data[row_num][1],'%m/%d/%Y') data[row_num][1]= date; data[row_num].append(float(value.replace('$', ''))) # ! append value csv_file.close() #creating lists of commodities,dates,locations commodities = list(set([x[0] for x in data])) dates = list(set([x[1] for x in data])) locations = list(set([x[2] for x in data])) # Filter object is not iterable and cannot be used as list comprehension # Hence convert to list before getting values select = list(filter(lambda x: x[0]=='Cauliflower' and x[2]=='New York',data)) date = [x[1] for x in select] price = [x[3] for x in select] # Change figure size to prevent overlapping fig,ax = plt.subplots(figsize=(20,10)) ax.plot(date,price,label="Cauliflower in New York") ax.set_xlabel('Date') ax.set_ylabel('Price in Dollors') # formatting the y axis to show dollors and cents fmt = '${x:,.2f}' # rename attributes to right one tick = mtick.StrMethodFormatter(fmt) ax.yaxis.set_major_formatter(tick) plt.legend() plt.show() #creating an output file to see new data in spreadsheet. resultfile = open('result.csv','w') writer = csv.writer(resultfile,lineterminator='\n') writer.writerows(data) resultfile.close() And use these codes
Answered 2 days AfterNov 29, 2021

Answer To: This the link for the steps to do it....

Sandeep Kumar answered on Dec 02 2021
125 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here