Hispanic/Latino Population and Crime in the U.S.

Data

Crime Data

The crime data used comes from fbi.gov, where the tables are available for download in .xlsx format. More specific descriptions of the data and the download links I used for each are below as well as an examples of how to read the data into a Juypter Notebook.

Crime by State
Each data file in this category corresponds to a particular year, and crime numbers are sorted by crime type (columns) for each state (rows) and for different reporting areas (also rows). Example code to view the data in a Jupyter Notebook:

'''
import pandas as pd
!wget 'https://ucr.fbi.gov/crime-in-the-u.s/2016/crime-in-the-u.s.-2016/tables/table-21/table-21a.xls/output.xls' -O 'crime_demographics_2016.xlsx'
df = pd.read_excel('crime_demographics_2016.xlsx') # read .xlsx into a pandas DataFrame
df[:12]
'''
(output table here)

Comments on columns in above table:

Most of the column names are named intuitively, but rigourous definitions and methodology information are provided in the Data Declaration on the FBI UCR website here.

Crime by Race and Ethnicity
Each data file in this set corresponds to a particular year, and crime numbers are sorted by crime type (rows) and by race or ethnicity (columns).
Example code to view the data in a Jupyter Notebook:

'''
import pandas as pd
!wget 'https://ucr.fbi.gov/crime-in-the-u.s/2016/crime-in-the-u.s.-2016/tables/table-21/table-21a.xls/output.xls' -O 'crime_demographics_2016.xlsx'
df = pd.read_excel('crime_demographics_2016.xlsx', header=6, nrows=31) # read .xlsx into a pandas DataFrame
df
'''
(output table here)

Comments on columns in above table:

Links to crime data files:
Crime by state (2018)
Crime by state (2017)
Crime by state (2016)
Crime by state (2015)
Crime by state (2014)
Crime by state (2013)
Crime by state (2012)
Crime by state (2011)
Crime by state (2010)
Crime by state (2009)
Crime by state (2008)
Crime by state (2007)
Crime by state (2006)
Crime demographics (2016)

Population and Immigration Data Data

Total Mexican Immigrants in the U.S.
This data table is from www.migrationpolicy.org and gives the number of Mexican immigrants in the U.S., the total number of immigrants in the U.S., and the Mexican immigrants as percentage of total immigrants in the U.S., from years 1850 to 2018. Note that data from 1850 - 2010 is available only by decade, while data from 2010-2018 is available by year. Example code to view the data in a Jupyter Notebook:

'''
import pandas as pd
!wget 'https://www.migrationpolicy.org/sites/default/files/datahub/MPI-Data-Hub_Mexican-Immigrants-US_2018.xlsx' -O 'mex_im_data.xlsx'
df = pd.read_excel('mex_im_data.xlsx', header=7,nrows=25) # read data into pandas DataFrame
df
'''
(output table here)

Immigrant Population by Year and State
This data table came from www.migrationpolicy.org, and shows the numbers of immigrants and percentage of immigrants in the population by state (rows) and year (columns). This data does not discriminate between immigrants of different races, ethnicities, or place of origin. The columns and rows are labeled unambiguously, although note that there are two headers rows: one for the year, and one for column categories within that year. The "unnamed" columns in the first header can be renamed for ease of use.
Example code to view the data in a Jupyter Notebook:

'''
import pandas as pd
!wget 'https://www.migrationpolicy.org/sites/default/files/datahub/MPI-Data-Hub_Immigrants_N-Percent-US-Population%20by%20State_2018.xlsx' -O 'im_pop_data.xlsx'
df = pd.read_excel('im_pop_data.xlsx', header=8, nrows=53) # read data into pandas DataFrame
df
'''
(output table here)

Hispanic and Latino Population by Year and State
This data includes total numbers of Hispanic and Latino people as well as percentages of population, sorted by state and year for 2000, 2010, 2012, 2015, 2016, and 2017. The data scraped from a table on wikipedia (link below) which was constructed using data from the U.S. Census Bureau. The
Example code to view the data in a Jupyter Notebook. I wrote a function for scraping the table, which I have made available for download as a python script: get_wiki_data.py The intended usage is shown below:

'''
import pandas as pd
from get_wiki_data import get_hisplat_wikidata
df, data = get_hisplat_wikidata() # data is a list of lists
df
'''
(output table here)
Comments on the data in the table above:

Links to population and immigration data files:
Immigrants-N-Percent-US-Population-by-State-2018
Mexican Immigrants in U.S. 1850-2018
Wikipedia: List_of_U.S._states_by_Hispanic_and_Latino_population