Want to learn more? Take the full course at https://learn.datacamp.com/courses/an... at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Census data are available for many different geographic levels, from the nation down to the Census block. In this lesson, we will learn about these geographies.
So far we have been requesting all US states at once. What if we only want the data for one state, say, Pennsylvania?
In that case, replace the star wild card with the state code, 42. This is the geographic identifier, or GEOID, for Pennsylvania. Where can we find these identifiers?
Although there are many sources online, in this lesson you will use the Geographic Codes Lookup website maintained by the Missouri Census Data Center.
The bureau reports summary statistics for both legal and statistical geographies. Legal/administrative geographies are those that exist as legally defined entities, such as states or counties. Statistical geographies, which include Census tracts, are created by the Census Bureau for purposes of statistical reporting. ZIP Code Tabulation Area, or "ZCTA" is a statistical equivalent to the postal ZIP Code.
These geographies exist in a hierarchy, with larger units built from smaller units. Census blocks are the smallest reporting unit and the building blocks for all other geographies. In this image, the connecting lines indicate nesting, so blocks nest in block groups, which nest in Census tracts, which nest in counties. But school districts, shown in green in the middle left of the chart, can cross county lines, so only blocks nest in school districts.
We can use this information to specify containing geography using the optional "in" predicate.
Here, we request all counties in two states: New Hampshire and Vermont. You cannot use a wildcard with the "in" predicate.
You can also request specific counties in one state. If you specify GEOIDs in the "for" predicate, you cannot use the "in" predicate to request more than one containing geography.
After the "in" predicate has been assigned, use requests.get to return a response object, the same as before.
"Place" is special geography that combines legal and statistical areas.
It includes Incorporated Places, legally existing municipal governments;
and Census Designated Places. These are defined in cooperation with local officials to provide data for areas that have a commonly used name but are not legally incorporated. CDPs can be quite large.
For example, the City of Los Angeles is an incorporated place. East Los Angeles is a Census Designated Place in Los Angeles County. Both are included if you request data for places in California.
This is a partial list of geographies available via API for the 2010 Census. The API does not expose all geographies that the Census Bureau reports on, and the geographies differ by data product. You can view the list for any data product by appending "geography.html" to the API base URL. An example of the 2010 Decennial Census is shown here. You will get familiar with these and other geographies throughout this course.
What about requesting data for geographies that don't nest cleanly,
for example, the state/congressional district/county hierarchy?
First, the "for" predicate must be set to "county (or part)", not just "county".
You must specify GEOIDs for each level up the hierarchy. "state:42; congressional district:02" request counties in the Second Congressional District in the state of Pennsylvania.
The result shows the two counties in the Second District, but the names indicate that they are part-counties. Demographic data are reported only for the parts of these counties that fall in the Second District.
You've learned about some important geographies for reporting Census data. Let's get some hands-on experience.
#DataCamp #PythonTutorial #AnalyzingUSCensusDatainPython #Census Geography #AnalyzeUScensusdata
Информация по комментариям в разработке