{"id":2458822,"date":"2024-08-13T13:34:01","date_gmt":"2024-08-13T20:34:01","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=2458822"},"modified":"2024-08-26T11:44:17","modified_gmt":"2024-08-26T18:44:17","slug":"map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","title":{"rendered":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python"},"author":317312,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[23341],"tags":[766402,24341,25631],"industry":[],"product":[36841],"class_list":["post-2458822","blog","type-blog","status-publish","format-standard","hentry","category-analytics","tag-justice40","tag-python","tag-spatial-analysis","product-api-python"],"acf":{"authors":[{"ID":317312,"user_firstname":"Elif","user_lastname":"Bulut","nickname":"Elif Bulut","user_nicename":"ebulut","display_name":"Elif Bulut","user_email":"ebulut@esri.com","user_url":"","user_registered":"2022-08-24 18:23:17","user_description":"Elif is a Product Engineer of Social Analysis and Data Science on the ArcGIS Business Analyst team. She holds a PhD in Sociology and applies spatial data science and social research to help users explore demographic trends, community characteristics, and access to resources. She is passionate about turning complex data into clear insights that support real-world decision-making.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/Elif-Bulut_Nov-24_2021_profie-pic.jpeg' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"short_description":"Explore how to map U.S. counties' predominant disadvantage categories using Justice40 data and ArcGIS API for Python.","flexible_content":[{"acf_fc_layout":"content","content":"<p><span data-contrast=\"auto\">The Justice40 Initiative is a federal effort to ensure that 40 percent of the benefits from federal investments reach disadvantaged communities across the United States. It targets inequities in eight key areas: Climate Change, Clean Energy, Clean Transit, Affordable Housing, Workforce Development, Legacy Pollution, Health Burdens, and Clean Water Infrastructure.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:0,&quot;335551620&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:240,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Esri has integrated the Justice40 Tracts from Council on Environmental Quality (CEQ) into ArcGIS Living Atlas of the World, enabling detailed mapping and analysis of these disadvantaged communities across the U.S. and its territories. By leveraging this data in ArcGIS, users can create maps that identify these communities and support deeper analysis and targeted interventions.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:0,&quot;335551620&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:240,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Because many policy decisions and resource allocations occur at the county level, aggregating data from census tracts to counties ensures that analysis is directly applicable to the administrative units responsible for implementing policies. In this article, we will use the ArcGIS API for Python and Justice40 data from Esri to map the predominant disadvantage categories at the county level across the U.S. <\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:0,&quot;335551620&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:240,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><strong>Importance of Identifying Predominant Disadvantage Category<\/strong><\/p>\n<p><span data-contrast=\"auto\">Identifying the predominant disadvantage category for each county involves determining which issue\u2014such as climate change, clean energy, housing, or health\u2014most affects the census tracts within that county. This is crucial because it highlights the primary challenge impacting the largest portion of the population, enabling more focused and effective policy interventions.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Additionally, aggregating racial and ethnic demographic data to the county level is essential for recognizing and addressing disparities. By analyzing the share of each racial and ethnic group within a county, policymakers can ensure that their efforts are inclusive and equitable, targeting the needs of all community members, particularly those who have been historically marginalized.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Overall, understanding the predominant disadvantage category in a county helps policymakers:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><b><span data-contrast=\"auto\">Prioritize resources<\/span><\/b><span data-contrast=\"auto\">: Allocate attention and funding to the most pressing issues within each county.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><b><span data-contrast=\"auto\">Develop targeted strategies<\/span><\/b><span data-contrast=\"auto\">: Tailor policies and programs to address the specific needs identified within the county.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><b><span data-contrast=\"auto\">Promote equity<\/span><\/b><span data-contrast=\"auto\">: Ensure that interventions are designed with a clear understanding of which communities and demographic groups are most affected.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">To create a map that visualizes the predominant disadvantage categories in U.S. counties using Justice40 data, we will follow these five steps:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n"},{"acf_fc_layout":"sidebar","content":"<ol>\n<li data-leveltext=\"%1.\" data-font=\"Times New Roman\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"#Connect-to-ArcGIS-Online-and-access-data.\"><span data-contrast=\"auto\">Connect to ArcGIS Online and access data.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Times New Roman\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"#Query-and-prepare-data.\"><span data-contrast=\"auto\">Query and prepare data.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Times New Roman\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"#Aggregate-data-to-the-county-level.\"><span data-contrast=\"auto\">Aggregate data to the county level.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Times New Roman\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"#Determine-predominant-disadvantage-categories.\"><span data-contrast=\"auto\">Determine predominant disadvantage categories.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/li>\n<li data-leveltext=\"%1.\" data-font=\"Times New Roman\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"#Merge-data-with-county-boundaries-and-publish-the-layer.\"><span data-contrast=\"auto\">Merge data with county boundaries and publish the layer.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/li>\n<\/ol>\n","image_reference":false,"layout":"standard","image_reference_figure":"","snippet":"","spotlight_name":"","section_title":"","position":"Center","spotlight_image":false},{"acf_fc_layout":"content","content":"<p id=\"Connect-to-ArcGIS-Online-and-access-data.\"><strong>Step 1: Import Required Libraries and Access Justice40 Data<span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/strong><\/p>\n<p><span data-contrast=\"auto\">First, we import the necessary libraries and connect to ArcGIS Online to access the Justice40 data.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\">import pandas as pd\r\nfrom arcgis.gis import GIS\r\n\r\n# Connect to ArcGIS Online account\r\ngis = GIS(\"https:\/\/www.arcgis.com\", \"username\", \"password\")\r\n\r\n# Retrieve the Justice40 data layer from ArcGIS Online\r\nitem_id = 'f95344889cab44bd84207052f44cb940'\r\njustice = gis.content.get(item_id)\r\njustice_layer = justice.layers[0]\r\n\r\n# Display available layers\r\nprint(\"\\n\".join([f\"{lyr.properties.id}: {lyr.properties.name}\" for lyr in justice.layers]))\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p id=\"Query-and-prepare-data.\"><strong>\u00a0Step 2: Query and Prepare Tract-Level Data\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">Next, we query the Justice40 data layer to retrieve data fields including population, disadvantage categories, and racial demographics. We then prepare this data for aggregation to the county level by adding essential columns, such as the county FIPS code and calculated fields like the number of people affected in each demographic group.\u00a0<\/span><\/p>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\"># Query the layer and convert to Spatially Enabled DataFrame \r\nlyr_df = justice_layer.query(out_fields=['GEOID10', 'SF', 'CF', 'TPF', 'N_WTR', 'N_WKFC', 'N_CLT', 'N_ENY', 'N_TRN', 'N_HSG', 'N_PLN', 'N_HLTH', 'CC', 'SN_C', 'DM_B', 'DM_AI', 'DM_A', 'DM_HI', 'DM_W', 'DM_H', 'DM_T'], out_sr=4326).sdf \r\n\r\n# First, ensure GEOID10 is a string\r\nlyr_df1['GEOID10'] = lyr_df1['GEOID10'].astype(str)\r\n\r\n# Extract the first 5 characters to get the state+county FIPS code\r\nlyr_df1['FIPS'] = lyr_df1['GEOID10'].str.slice(start=0, stop=5)\r\n\r\n# Create new columns for racial and demographic calculations \r\nlyr_df['African American'] = lyr_df['TPF'] * lyr_df['DM_B'] \r\nlyr_df['White'] = lyr_df['TPF'] * lyr_df['DM_W'] \r\nlyr_df['Asian'] = lyr_df['TPF'] * lyr_df['DM_A'] \r\nlyr_df['Hispanic'] = lyr_df['TPF'] * lyr_df['DM_H'] \r\nlyr_df['American Indian'] = lyr_df['TPF'] * lyr_df['DM_AI'] \r\nlyr_df['Native Hawaiian or Pacific'] = lyr_df['TPF'] * lyr_df['DM_HI'] \r\nlyr_df['Two or more races'] = lyr_df['TPF'] * lyr_df['DM_T'] \r\nlyr_df['Pop_in_Disadv_Tracts'] = lyr_df['TPF'] * lyr_df['SN_C'] \r\nlyr_df['FIPS'] = lyr_df['GEOID10'].str.slice(start=0, stop=5) \r\nlyr_df['Total_Tracts_Per_County'] = lyr_df.groupby('FIPS')['FIPS'].transform('size')\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p id=\"Aggregate-data-to-the-county-level.\"><strong>\u00a0Step 3: Aggregate Data to County Level\u00a0<\/strong><\/p>\n<p>In this step, w<span data-contrast=\"auto\">e aggregate the tract-level data to the county level to identify the predominant disadvantage category for each county. This is crucial for understanding which issues are most prevalent in each county in the U.S., allowing for targeted interventions.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span>We also calculate the percentage of different racial and ethnic groups within each county. This helps ensure that the analysis considers the diverse populations affected by the disadvantages.<\/p>\n<p>&nbsp;<\/p>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\"># Aggregate data at the county level \r\ncounty_level_df = lyr_df.groupby(['FIPS', 'SF', 'CF']).agg({ \r\n    'TPF': 'sum', \r\n    'N_WTR': 'sum', \r\n    'N_WKFC': 'sum', \r\n    'N_CLT': 'sum', \r\n    'N_ENY': 'sum', \r\n    'N_TRN': 'sum', \r\n    'N_HSG': 'sum', \r\n    'N_PLN': 'sum', \r\n    'N_HLTH': 'sum', \r\n    'SN_C': 'sum', \r\n    'African American': 'sum', \r\n    'White': 'sum', \r\n    'Asian': 'sum', \r\n    'Hispanic': 'sum', \r\n    'American Indian': 'sum', \r\n    'Native Hawaiian or Pacific': 'sum', \r\n    'Two or more races': 'sum', \r\n    'Pop_in_Disadv_Tracts': 'sum', \r\n    'Total_Tracts_Per_County': 'first' \r\n}).reset_index()\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\"># Calculate share of population in disadvantaged tracts and demographic percentages \r\ncounty_level_df['Share_of_Pop_in_Disadv_Tracts'] = county_level_df['Pop_in_Disadv_Tracts'] \/ county_level_df['TPF'] \r\ncounty_level_df['Share_of_African Americans'] = county_level_df['African American'] \/ county_level_df['TPF']\r\ncounty_level_df['Share_of_Whites'] = county_level_df['White'] \/ county_level_df['TPF'] \r\ncounty_level_df['Share_of_Hispanics'] = county_level_df['Hispanic'] \/ county_level_df['TPF'] \r\ncounty_level_df['Share_of_Asians'] = county_level_df['Asian'] \/ county_level_df['TPF'] \r\ncounty_level_df['Share_of_American_Indians'] = county_level_df['American Indian'] \/ county_level_df['TPF']\r\ncounty_level_df['Share_of_Native_Hawaiians'] = county_level_df['Native Hawaiian or Pacific'] \/county_level_df['TPF'] \r\ncounty_level_df['Share_of_Two_or_more races'] = county_level_df['Two or more races'] \/ county_level_df['TPF']\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p id=\"Determine-predominant-disadvantage-categories.\"><strong>Step 4: Identify the Predominant Disadvantage Category\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">Here, we identify the predominant disadvantage category for each county by determining which category is most prevalent.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"> The function,<code>find_predominant_category_explicit<\/code> , determines the predominant disadvantage category for each county. It checks whether the county has any disadvantaged tracts using the <code>Has_Disadv_Tract<\/code> flag. If there are no disadvantaged tracts, it returns &#8220;No Disadvantaged Tracts.&#8221; Otherwise, it iterates through each disadvantage category to find the one with the highest impact (i.e., the highest value). The function then returns the full name of the predominant category.<\/span><\/p>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\"># Create a flag for counties with disadvantaged tracts \r\ncounty_level_df['Has_Disadv_Tract'] = county_level_df['SN_C'] &gt; 0 \r\n\r\n# Define disadvantage categories and their names \r\ndisadvantage_categories = ['N_WTR', 'N_WKFC', 'N_CLT', 'N_ENY', 'N_TRN', 'N_HSG', 'N_PLN', 'N_HLTH'] \r\n\r\ncategory_names = { \r\n    'N_WTR': 'Water and Wastewater Disadvantaged', \r\n    'N_WKFC': 'Workforce Development Disadvantaged', \r\n    'N_CLT': 'Climate Change Disadvantaged', \r\n    'N_ENY': 'Energy Disadvantaged', \r\n    'N_TRN': 'Transportation Disadvantaged', \r\n    'N_HSG': 'Housing Disadvantaged', \r\n    'N_PLN': 'Legacy Pollution Disadvantaged', \r\n    'N_HLTH': 'Health Disadvantaged'} \r\n\r\n# Function to find predominant disadvantage category \r\ndef find_predominant_category_explicit(row): \r\n    if not row['Has_Disadv_Tract']: \r\n        return \"No Disadvantaged Tracts\" \r\n    max_value = -1 \r\n    max_category = None \r\n    for category in disadvantage_categories: \r\n        category_value = row[category] if pd.notnull(row[category]) else 0 \r\n        if category_value &gt; max_value: \r\n            max_value = category_value \r\n            max_category = category \r\n    return category_names[max_category] if max_category else \"No Disadvantaged Tracts\" \r\n\r\n# Apply the function to determine predominant category \r\ncounty_level_df['Predominant_Disadvantage'] = county_level_df.apply(find_predominant_category_explicit, axis=1)\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p id=\"Merge-data-with-county-boundaries-and-publish-the-layer.\"><strong>Step 5: Merge with County Boundaries and Publish as a Feature Layer\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">Finally, we merge the aggregated county-level data with geographic boundary data for each county. After merging, the dataset is published as a feature layer in ArcGIS, allowing for interactive analysis and visualization. This step ensures that the insights gained from the data are easily accessible and actionable, providing a valuable tool for policymakers and stakeholders.<\/span><\/p>\n"},{"acf_fc_layout":"content","content":"<pre><code class=\"language-python\"># Access county boundaries and merge with data \r\ncounty = gis.content.get('1f60b7a2c9f748909834367ed33197fd').layers[1] \r\ncounty_df = county.query(out_fields=['GEOID10'], out_sr=4326).sdf \r\ncounty_df.rename(columns={'GEOID10': 'FIPS'}, inplace=True)  \r\n\r\n# Merge the county-level data with the county boundaries \r\nmerged_df = pd.merge(county_level_df, county_df, on='FIPS', how='right') \r\nmerged_df.spatial.set_geometry('SHAPE', inplace=True) \r\n\r\n# Rename columns to ensure valid field names \r\nmerged_df.columns = [col.replace(' ', '_').replace('-', '_') for col in merged_df.columns] \r\n\r\n# Publish the merged data as a feature layer \r\nitem_properties = { \r\n    \"title\": \"County Predominant Disadvantage Category\", \r\n    \"description\": \"This layer highlights the primary category of disadvantage for each county in the United States, based on the Justice40 Initiative.\", \r\n    \"tags\": [\"Justice40\", \"disadvantage\", \"data science\", \"county level analysis\"] \r\n} \r\n\r\n# Publish as a feature layer to ArcGIS Online \r\nfeature_layer_item = merged_df.spatial.to_featurelayer( \r\n    title=item_properties['title'],  \r\n    gis=gis,  \r\n    tags=item_properties['tags'],  \r\n    description=item_properties['description'] \r\n)  \r\nprint(f\"Feature Layer created: {feature_layer_item.url}\")\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p><span data-contrast=\"auto\">You can access the final map through this <\/span><a href=\"https:\/\/esriss.maps.arcgis.com\/home\/item.html?id=86ef6237a42d4d5c9a678adbd451c459\"><span data-contrast=\"none\">link.<\/span><\/a><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<h3><b><span data-contrast=\"auto\">Conclusion<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">In this workflow, we used the ArcGIS API for Python to efficiently access, analyze, and visualize Justice40 data. By aggregating data from census tracts to counties, we identified key disadvantage categories and highlighted affected demographic groups at the county level. This aggregation is particularly important because it aligns with the administrative units where many policy decisions and resource allocations are made. This streamlined process not only simplifies complex data analysis but also supports data-driven policy decisions, ensuring resources are allocated where they are most needed. The ArcGIS API for Python is a powerful tool for quick, seamless workflows that enhance the effectiveness and precision of policy-making.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n"}],"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/08\/test-3.png","wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/08\/tets-2.png","related_articles":[{"ID":1943312,"post_author":"317312","post_date":"2023-05-26 08:28:28","post_date_gmt":"2023-05-26 15:28:28","post_content":"","post_title":"Creating an economic distress index layer using Census data with Python","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"creating-an-economic-distress-index-using-python","to_ping":"","pinged":"","post_modified":"2023-07-26 14:16:15","post_modified_gmt":"2023-07-26 21:16:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1943312","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"4","filter":"raw"},{"ID":2027882,"post_author":"317312","post_date":"2023-07-18 08:27:36","post_date_gmt":"2023-07-18 15:27:36","post_content":"","post_title":"Performing principal component analysis (PCA) to determine weights for index indicators","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"performing-principal-component-analysis-pca-to-determine-weights-for-index-indicators","to_ping":"","pinged":"","post_modified":"2023-07-25 15:08:24","post_modified_gmt":"2023-07-25 22:08:24","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=2027882","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"1","filter":"raw"}]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-26T18:44:17+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\"},\"author\":{\"name\":\"Elif Bulut\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/4387344ead563b42b8031495ffd80a5e\"},\"headline\":\"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python\",\"datePublished\":\"2024-08-13T20:34:01+00:00\",\"dateModified\":\"2024-08-26T18:44:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\"},\"wordCount\":11,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"Justice40\",\"python\",\"spatial analysis\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\",\"name\":\"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2024-08-13T20:34:01+00:00\",\"dateModified\":\"2024-08-26T18:44:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/4387344ead563b42b8031495ffd80a5e\",\"name\":\"Elif Bulut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/Elif-Bulut_Nov-24_2021_profie-pic.jpeg\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/Elif-Bulut_Nov-24_2021_profie-pic.jpeg\",\"caption\":\"Elif Bulut\"},\"description\":\"Elif is a Product Engineer of Social Analysis and Data Science on the ArcGIS Business Analyst team. She holds a PhD in Sociology and applies spatial data science and social research to help users explore demographic trends, community characteristics, and access to resources. She is passionate about turning complex data into clear insights that support real-world decision-making.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/elif-bulut-phd\/\"],\"gender\":\"Female\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/ebulut\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","og_locale":"en_US","og_type":"article","og_title":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2024-08-26T18:44:17+00:00","twitter_card":"summary_large_image","twitter_site":"@ESRI","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python"},"author":{"name":"Elif Bulut","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/4387344ead563b42b8031495ffd80a5e"},"headline":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python","datePublished":"2024-08-13T20:34:01+00:00","dateModified":"2024-08-26T18:44:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python"},"wordCount":11,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["Justice40","python","spatial analysis"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python","name":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2024-08-13T20:34:01+00:00","dateModified":"2024-08-26T18:44:17+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/api-python\/analytics\/map-the-predominant-disadvantage-categories-in-u-s-counties-using-justice40-data-with-arcgis-api-for-python#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Map Predominant Disadvantage with Justice40 Data Using ArcGIS API for Python"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/4387344ead563b42b8031495ffd80a5e","name":"Elif Bulut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/Elif-Bulut_Nov-24_2021_profie-pic.jpeg","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/Elif-Bulut_Nov-24_2021_profie-pic.jpeg","caption":"Elif Bulut"},"description":"Elif is a Product Engineer of Social Analysis and Data Science on the ArcGIS Business Analyst team. She holds a PhD in Sociology and applies spatial data science and social research to help users explore demographic trends, community characteristics, and access to resources. She is passionate about turning complex data into clear insights that support real-world decision-making.","sameAs":["https:\/\/www.linkedin.com\/in\/elif-bulut-phd\/"],"gender":"Female","url":"https:\/\/www.esri.com\/arcgis-blog\/author\/ebulut"}]}},"text_date":"August 13, 2024","author_name":"Elif Bulut","author_page":"https:\/\/www.esri.com\/arcgis-blog\/author\/ebulut","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/08\/tets-2.png","primary_product":"ArcGIS API for Python","tag_data":[{"term_id":766402,"name":"Justice40","slug":"justice40","term_group":0,"term_taxonomy_id":766402,"taxonomy":"post_tag","description":"","parent":0,"count":9,"filter":"raw"},{"term_id":24341,"name":"python","slug":"python","term_group":0,"term_taxonomy_id":24341,"taxonomy":"post_tag","description":"","parent":0,"count":173,"filter":"raw"},{"term_id":25631,"name":"spatial analysis","slug":"spatial-analysis","term_group":0,"term_taxonomy_id":25631,"taxonomy":"post_tag","description":"","parent":0,"count":62,"filter":"raw"}],"category_data":[{"term_id":23341,"name":"Analytics","slug":"analytics","term_group":0,"term_taxonomy_id":23341,"taxonomy":"category","description":"","parent":0,"count":1366,"filter":"raw"}],"product_data":[{"term_id":36841,"name":"ArcGIS API for Python","slug":"api-python","term_group":0,"term_taxonomy_id":36841,"taxonomy":"product","description":"","parent":36601,"count":157,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=api-python","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/2458822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/317312"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=2458822"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/2458822\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=2458822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=2458822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=2458822"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=2458822"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=2458822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}