始める無料で始める

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.

この演習はコースの一部です

Analyzing IoT Data in Python

コースを見る

演習の手順

  • 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.

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# 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())
コードを編集して実行