Search Results for: pa census

Any spatial dataframe you create in R, such as with tidycensus can be exported with write_sf to a shapefile

Any spatial dataframe you create in R, such as with tidycensus can be exported with write_sf to a shapefile.

I know this isn’t rocket science but it is a big time and headache saver. Sometimes joins don’t go quite right in QGIS due to your own silliness but if obtain the spatial data right at the same time as Census data using tidycensus geometry=True then you don’t have to manually join the data, deal with type issues or the wrong year TIGER line.

For example for the PA Poverty maps I poste on the Facebook:

library(tidycensus)
library(sf)

income <- get_acs(
geography = 'tract',
variables = 'S1701_C03_001',
state = 'PA',
geometry = T)

write_sf(income,'/tmp/pa_poverty.shp')

Here is a list of the ten most Hispanic counties in New York State from the 2020 US Census

Here is a list of the ten most Hispanic counties in New York State from the 2020 US Census.

CountyPercent Hispanic
Bronx54.7625579396111
Queens27.7643315385306
Westchester26.8138904900857
New York23.7650737700612
Orange22.3627619545987
Suffolk21.8202133794694
Rockland19.6409412140254
Richmond19.5583634394157
Kings18.8747087980808
Nassau18.3715271956635

Here is how you can create this list using PANDAS. You will need to get the PL-94 171 Redistricting data, the Legacy File Format Header Records, and expand the ZIP file and place in the appropriate directory described below.

import pandas as pd
import geopandas as gpd

# path where 2020_PLSummaryFile_FieldNames.xlsx XX=State Code
# and XXgeo2020.pl, xx000012020.pl through XX000032020.pl
# reside on your hard drive
path='/home/andy/Desktop/2020pl-94-171/'

# state code
state='ny'

# header file, open with all tabs as an dictionary of dataframes
field_names=pd.read_excel(path+'2020_PLSummaryFile_FieldNames.xlsx', sheet_name=None)

# load the geoheader, force as str type to mixed types on certain fields
# ensure GEOIDs are properly processed avoids issues with paging
gh=pd.read_csv( path+state+'geo2020.pl',delimiter='|',
               header=None, 
               names=field_names['2020 P.L. Geoheader Fields'].columns,
               index_col='LOGRECNO',
               dtype=str )
               
 # load segment 1 of 2020 PL 94-171 which is racial data 
segNum=1
seg=pd.read_csv( path+state+'0000'+str(segNum)+'2020.pl',delimiter='|',
               header=None, 
               names=field_names['2020 P.L. Segment '+str(segNum)+' Fields'].columns,
               index_col='LOGRECNO',
              )
# discard FILEID, STUSAB, CHARITER, CIFSN as duplicative after join
seg=seg.iloc[:,4:]

# join seg to geoheader
seg=gh.join(seg)

# Calculate the population of New York Counties that is African American 
# using County SUMLEVEL == 50 (see Census Docts)
ql="SUMLEV=='050'"

# Create a DataFrame with the County and Percent Hispani
# You can get the fields list from 2020 PL Summary FieldNames.xlsx
# under the 2020 P.L. Segment 1 Definitions tab
his=pd.DataFrame({ 'County': seg.query(ql)['BASENAME'], 
              'Percent Hispanic': seg.query(ql)['P0020002'] / seg.query(ql)['P0020001'] *100})

# Sort and print most Hispanic Counties
his.sort_values(by="Percent Hispanic", ascending=False).head(10).to_csv('/tmp/hispanics.csv')

Census won’t release key annual survey because of pandemic’s impact on data

Census won’t release key annual survey because of pandemic’s impact on data

The Census Bureau announced Thursday that it will not produce its annual American Community Survey, which provides detailed demographic data widely used for research and billions of dollars in federal funding decisions, because of how the coronavirus pandemic skewed survey results.

The data for the 2020 ACS did not meet agency standards, Census officials said. Instead, the agency will release an “experimental” dataset that includes less information than the normal release.

As a result of the pandemic, ACS responses skewed toward wealthier, more educated individuals — too many to account for with statistical adjustments, Donna Daily, chief of the bureau’s ACS office, told reporters. The Census Bureau could not move ACS data gathering from the height of the pandemic lockdowns last spring, unlike the delay the agency used for the decennial census.

Comparing to Electoral College votes to 2019 US Census Population estimates

Comparing to Electoral College votes to 2019 US Census Population estimates:

The ten most over represented states in the Electoral College:

Rhode Island, West Virginia, Wyoming, Vermont, District of Columbia, Nebraska, Alaska, Maine, New Hampshire and North Dakota.

States with representation in proportion to population in the Electoral College:

Maryland, Oregon, Indiana, Missouri and Tennessee.

The ten most under represented states in the Electoral College:

California, Texas, Florida, New York, North Carolina, Georgia, Ohio, Virginia, Pennsylvania and Arizona.