Assignment #06
Unit 06
Until next week, work through the material provided in Unit 6 and solve the following exercises in a notebook.
#06-01: Use datetime provided in WX
- Load WX_GNP.csv, the same data set we used in last unit’s assignment.
- How many records are available from 2019?
- Create a new data frame
WX19that contains all records from the 2018/19 winter season. Let’s take all records between September and Mai. The only meteorological variables we need in addition to the meta variablesstation_idanddatetimearetaandiswr. - Save
WX19as a new csv file.
Tip
Make sure you use an elegant pythonic approach to solve these datetime tasks, like demonstrated in Pandas: Index & datetime.
#06-02: Quick ’n dirty time series
- From
WX19, create a new data frameWXzoom1that contains the records from the first two weeks of January and anystation_idof your choice. - Using the
WXzoom1data frame, plot a line graph of the temperature that also shows the measurements with circles and, in a different figure, plot an area curve of the incoming shortwave radiation.
- Use the Pandas syntax to create quick ’n dirty working plots.
Tip
If your x-axis shows integers instead of dates and times, compare WXzoom1 before and after running the following line of code: WXzoom1.set_index('datetime', inplace=True). What changed? Run your plot command again. Do you now see a proper time series representation with time on the x-axis?
#06-03: Summary stats
- From
WX19, create a new data frameWXzoom2that contains the records from the first two weeks of January and the first twostation_id’s inWX19['station_id'].unique(). - Using the
WXzoom2data frame, what is the average temperature of each of the stations? - Using the
WXzoom2data frame, plot the temperature curves of both stations into one figure.
Tip
- Remember the pandas method
.isin()to filter for the station_ids. - Go back to the Pandas tutorials we worked through in Unit #5, if you’re struggling.
- Create a figure and axes using
plt.subplots()and then step-by-step fill the axes with the two lines one after another by subsettingWXzoom2to the individualstation_id’s.