Note: Please only use python standard libraries covered in class lectures (i.e. json, csv, urllib etc). Other libraries such as pandas, numpy are *not* allowed in your work. 1. This problem involves...

1 answer below »
Please see instructions in attachments.


Note: Please only use python standard libraries covered in class lectures (i.e. json, csv, urllib etc). Other libraries such as pandas, numpy are *not* allowed in your work. 1. This problem involves pulling data from public data APIs, deriving results from the data and outputting the computed results as a json file. You will utilize the APIs from MetaWeather (https://www.metaweather.com/api). For details on how to use their APIs to get weather data, please refer to the site’s documentation and the jupyter notebook that was covered in class. Write Python code to perform the following: i. Pull daily weather data for San Francisco for the month of February (2/1/2020 – 2/29/2020). Filter out all the forecast weather data (i.e. only include data which has the “applicable_date” on the same day as the “created” field). For example, the following shows the partial data (only created, applicable_date and the_temp are shown) for 2/27/2020. Only the rows with “created” on 2020-02-27 should be kept (shown in red) and all the others should be filtered out. You may notice that the first 3 rows have “created” date as 2/28 with the “applicable_date” of 2/27. The reason is that the datetime string for “created” is in UTC timezone which is 7 hours ahead of Pacific Daylight Time (PDT) and so those 3 rows are still technically data on 2/27 PDT. For simplicity, you don’t have to take this timezone offset into account and only include the rows that fall on the same day as the applicable date. ii. Compute the maximum, minimum and average temperature for each day in February from the temperatures extracted in previous step. For example, for 2/27, you will compute the maximum, minimum and average temperature using the 8 temperature values (in the red bold rows above) for that day. iii. Write out the maximum, minimum and average temperatures by day to a json file (temp_stats.json) and it should look like this(again the temperature values shown below are not the true values):
Answered Same DayMar 11, 2021

Answer To: Note: Please only use python standard libraries covered in class lectures (i.e. json, csv, urllib...

Ximi answered on Mar 12 2021
154 Votes
import urllib.request
import json
year = 2020
month = 2
dates = range(1, 30)
urls = [
    f"https
://www.metaweather.com/api/location/2487956/{year}/{month}/{date}/"
    for date in dates    
]
# --------------------------------------------------------------------------------------------------------
# Question 1
json_data = []
for url in urls:
    print ("API Request for: ", url)
    data = urllib.request.urlopen(url).read()
    json_data.append(json.loads(data))
def filter_created_applicable_dates(data):
    """Filters data...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here