MulaiMulai sekarang secara gratis

Load JSON data

Many open data portals make available JSONs datasets that are particularly easy to parse. They can be accessed directly via URL. Each object is a record, all objects have the same set of attributes, and none of the values are nested objects that themselves need to be parsed.

The New York City Department of Homeless Services Daily Report is such a dataset, containing years' worth of homeless shelter population counts. You can view it in the console before loading it to a dataframe with pandas's read_json() function.

Latihan ini adalah bagian dari kursus

Streamlined Data Ingestion with pandas

Lihat Kursus

Petunjuk latihan

  • Get a sense of the contents of dhs_daily_report.json, which are printed in the console.
  • Load pandas as pd.
  • Use read_json() to load dhs_daily_report.json to a dataframe, pop_in_shelters.
  • View summary statistics about pop_in_shelters with the dataframe's describe() method.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Load pandas as pd
____

# Load the daily report to a dataframe
pop_in_shelters = ____

# View summary stats about pop_in_shelters
print(____)
Edit dan Jalankan Kode