Note: Please only use python standard li
aries covered in class lectures (i.e. json, csv, urllib
etc). Other li
aries 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 Fe
uary (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 XXXXXXXXXXshould 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
Fe
uary 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
elow are not the true values):