Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The file for plant _ data looks something like the picture shown. Write this code in python. table [ [ , A , B

The file for plant_data looks something like the picture shown. Write this code in python.
\table[[,A,B,C,D,E,F,G,H#use the csv library to read Atmosphere Temperature, Soil Temperature, Atmosphere Humidity and Soil Humidity from Plant_Data.csv. Don't forget to close your file at the end!
#1.Create a function to read each variable into a dictionary using the csv.DictReader() function
#2.Inside of that same function, use a for loop to append each of the value pairs for each category to an empty list
#3.Pass these lists to another function that will calculate the averages if the values in each list (Hint: Make sure your data is the correct data type)
#4.Use the function to return these averages to the main(). Display the 4 average values inside main() with 2 digit precision.
import csv
from statistics import mean
def read_to_list():
#### Fix Me ####
with open('''PATH TO DATA''') as csvfile:
#create dictionary with key value pairs foratm tep, atm hum, soil hum and soil temp
reader = csv.DictReader(csvfile)
#create empty lists for values for each month (7 key value pairs)
atm_temp_avg =[]
soil_temp_avg =[]
atm_hum_avg =[]
soil_hum_avg =[]
#append each value pair of dictionary to list
for i in reader:
#### Fix Me ####
#### Fix Me ####
return ????
def calc_avgs(????):
#convert hum and temp values to floats
average_atm_temp =0
average_soil_temp =0
average_atm_hum =0
average_soil_hum =0
#convert hum and temp values to floats
#average_atm_temp = mean(map(float, atm_temp_avg))
for j in a_t:
average_atm_temp ???
average_atm_temp /= len(a_t)
#### Fix Me ####
for ...???
#### Fix Me ####
for...???
#### Fix Me ####
for...???
#### Fix Me ####
return ????
# Main function
def main():
#### Fix Me ####
????= read_to_list()
????= calc_avgs(????)
#show total averages
#### Fix Me ####
print(????)
print(????)
print(????)
print(????)
#call main to kick it off
#### Fix Me ####
????
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions