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

Congressional Districts by State

A Pennsylvania-based family advocacy nonprofit wants to find the average family size by Congressional district, so that they can call representatives from districts with relatively large families. For this exercise you will have to know the GEOID (ANSI Code) for Pennsylvania. If you don't remember it from a previous exercise, use the Geographic Codes Lookup at the Missouri Census Data Center.

The requests and pandas (as pd) packages have been imported. The base_url is defined, as is the predicates dictionary with the list of variables to request.

Bu egzersiz

Analyzing US Census Data in Python

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

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Build dictionary of predicates and execute the request
predicates[____] = ____
predicates[____] = ____
r = requests.get(base_url, params=predicates)

# Construct the DataFrame
col_names = ["name", "avg_family_size", "state", "cd"]
cd = pd.DataFrame(columns=col_names, data=r.json()[1:])
Kodu Düzenle ve Çalıştır