Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I am working on a Python project. For the project, I have to read temperatures (average monthly temperatures from 2000-2018 in four cities) from

Hi, I am working on a Python project. For the project, I have to read temperatures (average monthly temperatures from 2000-2018 in four cities) from a csv file, convert the temperatures from Celsius to Fahrenheit, and graph all the data on one graph. This is what I have so far: import csv import numpy as np import matplotlib.pyplot as plt def main(): open(data.csv, "r") Oslo =[] Harrisburg =[] Honolulu =[] Santiago =[] new_array=[] for year in range(2000,2018): for month in range(1,12): Oslo.append(value1) Harrisburg.append(value2) Honolulu.append(value3) Santaiago.append(value4) new_array.append(year) plt.plot(new_array, Oslo, 'b-', label = "Oslo") plt.plot(new_array, Harrisburg, 'r-', label = "Harrisburg") plt.plot(new_array, Honolulu, 'g-', label = "Honolulu") plt.plot(new_array, Santiago, 'y-', label = "Santiago") plt.legend(shadow = True, loc = "best") plt.xticks(np.arange(0, 216, 1.0)) plt.yticks(np.arange(min(temperature), max(temperature), 10.0)) plt.xlabel('Year') plt.ylabel('Temperature') plt.title("Average Monthly Temperature in Four Cities") plt.show() main() I think my main obstacle right now is how to open the csv file, because when I try to run the program, I get an error that says: "NameError: name 'data' is not defined". Any help is greatly appreciated. Thank you.

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions