{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Generate national and state-level crosswalks\n", "## 2000 block group parts to 2010 tracts\n", "\n", "### NHGIS [block crosswalks](https://www.nhgis.org/user-resources/geographic-crosswalks)\n", "\n", "**James D. Gaboardi, 06/2020**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2020-08-19T22:54:51.123976Z", "start_time": "2020-08-19T22:54:51.012145Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2020-08-19T18:54:51-04:00\n", "\n", "CPython 3.8.5\n", "IPython 7.16.1\n", "\n", "compiler : Clang 10.0.1 \n", "system : Darwin\n", "release : 19.6.0\n", "machine : x86_64\n", "processor : i386\n", "CPU cores : 8\n", "interpreter: 64bit\n" ] } ], "source": [ "%load_ext watermark\n", "%watermark" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2020-08-19T22:54:51.413338Z", "start_time": "2020-08-19T22:54:51.126049Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "watermark 2.0.2\n", "numpy 1.19.1\n", "nhgisxwalk 0.0.9\n", "pandas 1.1.0\n", "\n" ] } ], "source": [ "import nhgisxwalk\n", "import inspect\n", "import numpy\n", "import pandas\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n", "%watermark -w\n", "%watermark -iv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Source and target years for the crosswalk" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2020-08-19T22:54:51.434593Z", "start_time": "2020-08-19T22:54:51.416152Z" } }, "outputs": [], "source": [ "source_year, target_year = \"2000\", \"2010\"\n", "gj_src, gj_trg = \"GJOIN%s\"%source_year, \"GJOIN%s\"%target_year" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2020-08-19T22:54:51.454021Z", "start_time": "2020-08-19T22:54:51.436294Z" } }, "outputs": [], "source": [ "data_in = \"../../crosswalks/\"\n", "data_tab = \"../../tabular_data/\"\n", "block_file = \"%s_block\" % source_year" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Source-target building base" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2020-08-19T22:55:04.783556Z", "start_time": "2020-08-19T22:54:51.455409Z" } }, "outputs": [ { "data": { "text/html": [ "
| \n", " | GJOIN2000 | \n", "GJOIN2010 | \n", "WEIGHT | \n", "PAREA | \n", "
|---|---|---|---|---|
| 0 | \n", "G01000100201001000 | \n", "G01000100201002000 | \n", "0.035897 | \n", "0.008988 | \n", "
| 1 | \n", "G01000100201001000 | \n", "G01000100201002001 | \n", "0.253330 | \n", "0.263725 | \n", "
| 2 | \n", "G01000100201001000 | \n", "G01000100201002002 | \n", "0.000000 | \n", "0.000385 | \n", "
| 3 | \n", "G01000100201001000 | \n", "G01000100201002003 | \n", "0.076297 | \n", "0.055430 | \n", "
| 4 | \n", "G01000100201001000 | \n", "G01000100201002004 | \n", "0.032441 | \n", "0.007543 | \n", "