Question

Hello! I have this python Homework due tonight that I don't know how to do. Here...

Hello! I have this python Homework due tonight that I don't know how to do. Here is a document with the data in the csv file, as I didn't know how to share it

https://docs.google.com/document/d/1bDJVR2MqWKInvw5u0r3fOG3-CBmu3BEiPZwlaq_CShQ/edit?usp=sharing

Activity #3: On the class website is a CSV file containing weather data from Coulter Field (in Bryan) for 3 years (1 day is missing for some reason!); the data was taken from Weather Underground (wunderground.com). There are different versions of the file for Windows and Mac; the only difference is whether the end of a line contains just a new-line character, or both a new-line and a carriage return (you don’t need to worry about the difference). Open the file in any text browser and you should see what it is. Note that the first line of the file contains the column headers explaining what each column is. Download the file to your system, and write a program that will read in the file and do the following: a. Output the maximum and minimum temperature seen over the 3 year period b. Output the average daily precipitation c. Pick any 3 other “interesting” data analysis questions (of your choice) and output the answer to that question. For at least one, make use of the date information. Here are some ideas, but you can pick whatever you want: a. For some particular day, such as December 25, find the maximum and minimum temperatures reached among the 3 years of data. b. For some particular month, such as July 2015, calculate the average high temperature. c. Calculate how frequently the pressure increases from one day to another vs. how frequently it decreases. d. Calculate the percentage of days when the humidity was above some value, like 90%. e. Calculate the mean and standard deviation of precipitation levels. Be sure to include a descriptive sentence for what you are printing out in each case. Note that the “interesting” analysis questions you choose should be different analyses from each other; for example, you should not find the min/max temperature for just 3 different dates, or find the min/max pressure for December 25, since those are essentially the identical computation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code--

import pandas as pd
import statistics

weather_report=pd.read_csv('weather file.csv')


max_temp=max(weather_report['Temp High'])
min_temp=min(weather_report['Temp Low'])
print('Maximum and minimum temperature seen over the 3 years are',max_temp,'and',min_temp)

total_days=weather_report.shape[0]
sum_of_percipitation_values=sum(weather_report['Precipitation (in.)'])
print('The average percipitation value is ',sum_of_percipitation_values/total_days)

def resolve_date(date):
day=0
month=0
year=0
flag=0
for ch in date:
if(ch=='/'):
flag+=1
continue
if(flag==0):
month=month*10+int(ch)
elif(flag==1):
day=day*10+int(ch)
else:
year=year*10+int(ch)
return day,month,year


#calculating average high temperature for July 2015
sum_of_high_temperature=0
days_in_july15=0
for i in range(weather_report.shape[0]):
date=weather_report['Date'][i]
day,month,year=resolve_date(date)

#print(month==7,year)
if(month==7 and year==2015):
sum_of_high_temperature+=weather_report['Temp High'][i]
days_in_july15+=1
  


print('Average of high temperatures in July 2015 is ',sum_of_high_temperature/days_in_july15)
  
days_where_humidity_greater_than_90=0

for i in weather_report['Humidity Avg']:
if i>90:
days_where_humidity_greater_than_90+=1

print('The percentage of days with humidity greater than 90 is',100*(days_where_humidity_greater_than_90/total_days))


print('The mean and standard deviation of Precipitation are ',statistics.mean(weather_report['Precipitation (in.)']),statistics.stdev(weather_report['Precipitation (in.)']))

//////////////////Code ends here////////////

Code photo for indentation problem--

As you can see the variables have self explanatory names,

You will see there is a function resolve_date, what it does is it takes a string input which is (m/d/y) and returns the month,day and year value

Sample output

NOTE-- PUT the csv file in same directory as the python code file.

Add a comment
Know the answer?
Add Answer to:
Hello! I have this python Homework due tonight that I don't know how to do. Here...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a C++ program that reads daily weather observation data from a file and writes...

    1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...

  • Hi im having trouble with this homework question. Can someone show me how to do this in C++ with all the steps? Weather Analysis WeatherAnalyzer - New Day Data 2- Good Days 3- Summary 0- Exit Step 0:...

    Hi im having trouble with this homework question. Can someone show me how to do this in C++ with all the steps? Weather Analysis WeatherAnalyzer - New Day Data 2- Good Days 3- Summary 0- Exit Step 0: You can get the sample file from this link: Each row in the text file represent weather measurement of a day. For each day, the file contains the temperature (first column), humidity (second column) and the wind (third column) values emp 70...

  • Python function: This is my code and I don't know how to add the column to...

    Python function: This is my code and I don't know how to add the column to the csv file: def write_with_averages(read,write): with open (read,'r') as f_in: header = f_in.readline() reader=csv.reader(f_in) with open (write,'w') as f_out: writer=csv.writer(f_out) New_data=[] for Name, Test1, Test2, Test3 in reader: Total=(float(Test1)+float(Test2)+float(Test3)) average=Total/3 New_data.append(average) Hint: Skip the first line of the file as it is a header line Hint: All values come in as strings, so convert to floats before mathematical comparisons and calculations. File Format Name,Test1,Test2,Test3...

  • Create a program, Weather.java, which loads an unsorted set of weather data for Pendleton, sorts the...

    Create a program, Weather.java, which loads an unsorted set of weather data for Pendleton, sorts the data by date (handling date errors), and performs some analysis of the data (e.g. min/max temperature), and outputs the sorted data set to a file. Sample data: 2015-12-12,47,43,38,32,12,39,0.09,7,Rain,205 2015-05-08,73,56,38,18,7,22,0,0,,75 2015-11-10,51,44,37,18,8,21,0,4,,261 2016-02-02,45,36,26,12,5,14,0,1,,111 2015-06-28,109,89,68,38,11,48,T,0,Rain-Thunderstorm,296 Write methods to calculate each of the following on the given data set: Max. temperature Min. temperature Max. wind gust Max. precipitation and what the 'events' were for that day Each result...

  • In the lectures about lists we have seen some Python code examples that involve the processing of...

    In the lectures about lists we have seen some Python code examples that involve the processing of lists containing weather statistics. The original source of the values shown in the slides was taken from part of the Environment Canada website that serves up historical data: http://climate.weather.gc.ca/historical_data/search_historic_data_e.html    Data can be provied by that website using the Comma Separated Value (CSV) format which is stored in text files normally using a CSV suffix. We will not work directly with such files in...

  • 23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4...

    23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...

  • I need help on these functions PYTHON 3. The information about the functions is in the...

    I need help on these functions PYTHON 3. The information about the functions is in the first two pics. Scenario The Pokemon franchise consists of over 60 video games, 15 movies, several TV shows, a trading card game, and even a musical. It has been around for over two decades and at this point has fans of all ages. Because of this, people have become somewhat analytical about how they play the games. To help players of the Pokemon video...

  • Two Part coding quesiton. Python only please Part B: The second task is to write that...

    Two Part coding quesiton. Python only please Part B: The second task is to write that output to a file. The steps are 1. Open a file for writing, e.g. outfile = open(“output.txt”,”w”) 2. Whenever you print, include the argument file = outfile For example, if you previously had print(x) you will now have print(x, file = outfile) 3. Close the file, e.g. outfile.close() a Amazon.com: Kuzy BLACI x ht Macbook Case I Glaze P x f Microsoft Word labo6.doc...

  • Can someone help me with this problem? I have been struggling with Python 3 for a...

    Can someone help me with this problem? I have been struggling with Python 3 for a while now and not even the professor would help me solve this problem. I have to import a file called grades.csv and use error handling for a mid-semester report. please help me, I have been having trouble understand import csv. You don't have to check for errors or anything like that. I just have to display the mid-semester report This project will have you...

  • I need help using python ( spyder) only use files , loops if needed is statement do not use , def...

    i need help using python ( spyder) only use files , loops if needed is statement do not use , def function or any other. Exercise 1: Daily temperature is recorded for some weeks in files (templ.txt", temp2.txt, and temp3.txt; provided in the MOODLE). The first line contains number of weeks and the rest of the lines each represent the week number followed by temperature on the seven days of that week (see samples input files below). Write a python...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT