Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi! I have a question about Python. For my project, I have to read temperatures from a csv file and create a graph with those

Hi! I have a question about Python. For my project, I have to read temperatures from a csv file and create a graph with those values. My graph needs to use the years 2000-2017 as x-axis labels, but also have tickmarks for the months. I also need to convert all the temperatures from Celsius to Fahrenheit. I assume I need to use a nested for loop to extract the data (one loop for the year and one for the month), but I am unsure how to write the loop, especially to keep the previous value when the loop runs again. Here is what I have so far:

import numpy as np import matplotlib.pyplot as plt

def main(): temps = open(data.csv, "r") for year == "2000": for month == "1": Oslo = Harrisburg = Honolulu = Santaiago = years = np.linspace(2000, 2017, 17)

plt.plot(years, Oslo, 'b-', label = "Oslo") plt.plot(years, Harrisburg, 'r-', label = "Harriburg") plt.plot(years, Honolulu, 'g-', label = "Honolulu") plt.plot(years, Santiago, 'y-', label = "Santiago") plt.legend(shadow = True, loc = "best")

plt.xticks(np.arange(0, 12, 1.0)) plt.yticks(np.arange(0, max(temperature), 10.0))

plt.xlabel('Year') plt.ylabel('Temperature')

plt.title("Average Monthly Temperature in Four Cities")

plt.show() main()

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

2. What type of team would you recommend?

Answered: 1 week ago

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago