<jupyter_start><jupyter_text>How to GeoCodeThe purpose of this notebook is to illustrate how to use `ZGeo`, a module that converts address to Census Geographic Identifiers (GEOIDs).<jupyter_code>%load_ext autoreload
%autoreload 2
%config Completer.use_jedi=False
from os.path import join, expanduser, dirname
import pandas as pd
import sys
import os
import re
import warnings
warnings.filterwarnings(action='ignore')
home = expanduser('~')

src_path = '{}/zrp'.format(home)
sys.path.append(src_path)
from zrp.prepare.prepare import ZRP_Prepare, ZGeo
from zrp.prepare.utils import load_file<jupyter_output>/home/kam/.conda/envs/zrp_q1_22/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
  return f(*args, **kwds)<jupyter_text>Load sample data for predictionLoad processed list of New Jersey Mayors downloaded from https://www.nj.gov/dca/home/2022mayors.csv<jupyter_code>nj_mayors = load_file("../2022-nj-mayors-sample.csv")
nj_mayors.shape
nj_mayors<jupyter_output><empty_output><jupyter_text>Geocode  To map addresses to GEOIDs we will use `ZGeo` Input data into the prediction/modeling pipeline is tabluar data with the following columns: first name, middle name, last name, house number, street address (street name), city, state, zip code, and zest key. The `ZEST_KEY` should be specified to establish correspondence between inputs and outputs; it's effectively used as an index for the data table. Geocoding does not require first name, middle name, and last name but it is best practice to include these columns if the intention is to return race & ethnicity proxies.`ZGeo` is used to map addresses to block group, census tract, and other Census geographic identifiers. When called, the `.transform()` function's processing steps can include processing input data and geocoding the data.<jupyter_code>%%time
geocode = ZGeo()
geocode.fit()<jupyter_output>CPU times: user 25 µs, sys: 23 µs, total: 48 µs
Wall time: 64.1 µs<jupyter_text>Notes about the `.transform()` parameters:- `geo = 34` indicates we want to geocode addresses from NJ    - The state FIPs for NJ is 34. The user is required to input the numeric state FIPs if using ZGeo alone. Please refer to the inverse_state_mapping.json for assitance with mapping state abbreviation to state FIPs.- The output data may be larger in size than the input data since `replicate` is set to True.- No data is out because `save_table` is set to False. If True then the geocoded data will be saved to a file by state fips<jupyter_code>zrp_output = geocode.transform(nj_mayors, geo='34', processed=False, replicate=True, save_table=False)<jupyter_output>0%|          | 0/462 [00:00<?, ?it/s][Parallel(n_jobs=49)]: Using backend ThreadingBackend with 49 concurrent workers.
[Parallel(n_jobs=49)]: Done 102 tasks      | elapsed:    0.0s
100%|██████████| 462/462 [00:00<00:00, 13167.77it/s]<jupyter_text>Inspect the output<jupyter_code>zrp_output.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08811005568293481, 'fraction_numerical': 0.026858827382902063, 'mean_word_length': 5.6103896103896105, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '414840', 'license': 'Apache-2.0', 'n_tokens_mistral': 1038, 'n_tokens_neox': 941, 'n_words': 357, 'path': 'examples/prepare/zsub_prepare_Geocoding.ipynb', 'repo_name': 'zestai/zrp', 'size': '3053'}