Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python Thanks!! Assignment Background This exercise is (again) about data

ID: 3850011 • Letter: U

Question

Using Python

Thanks!!

Assignment Background This exercise is (again) about data manipulation. In this project we will process agricultural data, namely the adoption of different Genetically Modified (GM) crops in the U.S (http://www.ersusda.gov). The data was collected over the years 2000-2016. The issue of GM food adoption has been a topic ofcontroversy in recent years. In this project we are interested in how the adoption of different GM food and non-food crops has been proceeding in different states. We are going to determine the minimum and maximum adoption by state and the years when the minimum and maximum occurred. Assignment Specifications The data files The data files that you use are yearly state-wise percentage plantings for each type of crop: alltablesGEcrops.csv: the actual data from the USDA. data 1. csv: data modified to test this project. data2.csv: data modified to test this project, but you do not get to see it

Explanation / Answer

import csv
from itertools import izip
with open('source.csv') as f:
reader = csv.reader(f)
# filter data
data = (row for row in reader if row[1].strip() in ('5', '8'))
# make a new variable
data = (row + [int(row[2]) * 3] for row in data)
# transpose data
data = izip(*data)
# write data to a new csv file
with open('destination.csv', 'w') as fw:
csv.writer(fw).writerows(data)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote