MulaiMulai sekarang secara gratis

Store data

After consuming an API endpoint, it's often desirable to store the data to disk.

Some of the reasons we might want to store data are:

  • archive reproducible results
  • train ML Models

You will now consume the same api as you did in previous exercises, but this time you will store the data in both JSON and CSV format.

After running this code (not via submit Answer) you can also verify the data you saved using !head filename.

URL has been defined for you.

Latihan ini adalah bagian dari kursus

Analyzing IoT Data in Python

Lihat Kursus

Petunjuk latihan

  • Load json data from URL and store it in the variable df.
  • Store the data in JSON format as file "temperature.json", using "records" orientation.
  • Store df_temp with the filename "temperature.csv" as CSV without index.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import pandas
import pandas as pd

# Load URL to DataFrame
df_temp = ____

# Save DataFrame as json
df_temp.____(____, ____=____)

# Save DataFrame as csv without index
df_temp.____(____, ____=____)
Edit dan Jalankan Kode