Get startedGet started for free

Data acquisition

Let's get our first set of IoT data.

You will get started by consuming an environmental API provided by a public community. The API consists of multiple endpoints, and you will start by consuming the temperature data. The data is in 10-minute intervals and limited historical data is available.

You will use requests to download the last 5 records. Since the endpoint provides json encoded data, you can use .json() on the response object to get a python object (in this case a list).

Then you convert the list to a pandas DataFrame to be able to easily work with the data.

The constant URL to consume data from has been defined for you. Please note that this URL is different from the URL used in the video.

This exercise is part of the course

Analyzing IoT Data in Python

View Course

Exercise instructions

  • Import requests and pandas as pd.
  • Download data from URL using requests and store the result in res.
  • Convert the JSON-encoded result res into a python object and store the result in data_temp.
  • Convert data_temp into a pandas DataFrame df_temp.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Imports
____
____

# Download data from URL
res = ____

# Convert the result
data_temp = ____
print(data_temp)

# Convert json data to DataFrame
df_temp = pd.____(____)

print(df_temp.head())
Edit and Run Code