BaşlayınÜcretsiz Başlayın

Handle deeply nested data

Last exercise, you flattened data nested down one level. Here, you'll unpack more deeply nested data.

The categories attribute in the Yelp API response contains lists of objects. To flatten this data, you'll employ json_normalize() arguments to specify the path to categories and pick other attributes to include in the dataframe. You should also change the separator to facilitate column selection and prefix the other attributes to prevent column name collisions. We'll work through this in steps.

pandas (as pd) and json_normalize() have been imported. JSON-formatted Yelp data on cafes in NYC is stored as data.

Bu egzersiz

Streamlined Data Ingestion with pandas

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Flatten businesses records and set underscore separators
flat_cafes = ____(data["businesses"],
                  ____)

# View the data
print(flat_cafes.head())
Kodu Düzenle ve Çalıştır