In a previous post I embedded a Jupyter Notebook that used DarkSky’s API to pull weather data about a random location in Amsterdam. In this post I display some of the graphs plotted from the data.
The data consists of 168 data points, these are hourly predictions of the weather in Amsterdam. The data ranges from November 9th 19:00 to November 16th 19:00.
Unfortunately, I was not able to properly save the plots as images. Therefore, to read the x axis you might have to resort to some eye squinting and zooming in (ctrl + scroll up).
After I loaded the API data into a dataframe, I looked through DarkSky’s documentation to understand the data. The API call that I used mostly fetched data in units from the imperial system. As I am more familiar with the metric system, I used formulas to change to convert it to other units. Second, I changed the Unix time column in the dataframe to ‘datetime’. I also added a shortened version of the time for it to be more legible on the x axis of the plots.
You should also be able to fetch data in units from the metric system through the API. However, I wanted to play around with the units myself.
# Fahrenheit to celsius df['temperature'] = (df['temperature'] - 32) * (5/9) df['apparentTemperature'] = (df['apparentTemperature'] - 32) * (5/9) df['dewPoint'] = (df['dewPoint']- 32) * (5/9)
# Miles to kilometers df['visibility'] = df['visibility'] * 1.609344
# Unix to datetime df['time'] = pd.to_datetime(df['time'],unit='s')
# Changing the datetime format # I want to see: day, shortened month name & hour and minutes df['time_short'] = df['time'].dt.strftime('%d %b %H:%M')
In order to plot these graphs, I used matplotlib. To save the images, I used:
Temperatures in Amsterdam
This line graph displays two different lines. The blue line predicts the actual temperatures per hour. The orange line shows what the actual temperature will feel like.
Precipitation in Amsterdam
This line graph shows the precipitation in milliliters per hour.
Wind speeds in Amsterdam
This line graph shows the wind speeds in Amsterdam in kilometers per hour.
Dew points in Amsterdam
This line graph shows the different dew points over the course of time in Amsterdam, the data points are in degree Celsius.
Want to use this weather API?
Go to DarkSky‘s website, make an account and get your own free key!