|
1 | 1 | --- |
2 | 2 | title: TAZ & Regional Median Income |
3 | 3 | subtitle: Calculating Median Income for Transportation Analysis Zones (TAZ) |
4 | | -description: This notebook replicates the '_Source - TAZ & Regional Median Income - 2022-03-17.xlsb' tab from the 2019-2023 American Community Survey. It calculates the median income for each Traffic Analysis Zone (TAZ) based on household income data and household data. |
| 4 | +description: This notebook replicates the analysis from the '_Source - TAZ & Regional Median Income - 2022-03-17.xlsb' using the updated household and household income data from the 2019-2023 American Community Survey. |
5 | 5 | author: |
6 | 6 | - name: Pukar Bhandari |
7 | 7 | |
@@ -130,7 +130,7 @@ df_CPI = pd.read_excel( |
130 | 130 | df_CPI |
131 | 131 | ``` |
132 | 132 |
|
133 | | -### ACS_5YR_County |
| 133 | +### ACS_5YR_HouseholdIncome |
134 | 134 |
|
135 | 135 | #### Set Census Variables |
136 | 136 |
|
@@ -425,47 +425,6 @@ plt.show() |
425 | 425 |
|
426 | 426 | ### BlockSplit_wCOTAZID |
427 | 427 |
|
428 | | -```{python} |
429 | | -
|
430 | | -``` |
431 | | - |
432 | | - |
433 | | -## Lookup Tables |
434 | | - |
435 | | -### ACS Column ID to Label |
436 | | - |
437 | | -```{python} |
438 | | -lookup_hhinc = pd.DataFrame({ |
439 | | - "Income Category": [ |
440 | | - "HH_LT_10K", "HH_10_15K", "HH_15_20K", "HH_20_25K", "HH_25_30K", "HH_30_35K", |
441 | | - "HH_35_40K", "HH_40_45K", "HH_45_50K", "HH_50_60K", "HH_60_75K", |
442 | | - "HH_75_100K", "HH_100_125K", "HH_125_150K", "HH_150_200K", "HH_GT_200K" |
443 | | - ], |
444 | | - "Lower Limit": [ |
445 | | - 0, 10000, 15000, 20000, 25000, 30000, |
446 | | - 35000, 40000, 45000, 50000, 60000, |
447 | | - 75000, 100000, 125000, 150000, 200000 |
448 | | - ], |
449 | | - "Upper Limit": [ |
450 | | - 9999, 14999, 19999, 24999, 29999, 34999, |
451 | | - 39999, 44999, 49999, 59999, 74999, |
452 | | - 99999, 124999, 149999, 199999, np.inf |
453 | | - ] |
454 | | -}) |
455 | | -
|
456 | | -# Compute midpoint and round it |
457 | | -lookup_hhinc['Midpoint'] = ( |
458 | | - (lookup_hhinc['Lower Limit'] + lookup_hhinc['Upper Limit']) / 2 |
459 | | -).round() |
460 | | -
|
461 | | -# Replace infinite midpoint (last category) with 300000 |
462 | | -lookup_hhinc.loc[np.isinf(lookup_hhinc["Upper Limit"]), "Midpoint"] = 300000 |
463 | | -
|
464 | | -lookup_hhinc |
465 | | -``` |
466 | | - |
467 | | -### BlockGroupID for TAZ Centroid (Use if No HH in TAZ) |
468 | | - |
469 | 428 | ```{python} |
470 | 429 | # Define a function for population weighted interpolation |
471 | 430 | def interpolate_pw(from_gdf, to_gdf, weights_gdf, to_id=None, extensive=True, |
@@ -656,6 +615,47 @@ def interpolate_pw(from_gdf, to_gdf, weights_gdf, to_id=None, extensive=True, |
656 | 615 | return result |
657 | 616 | ``` |
658 | 617 |
|
| 618 | + |
| 619 | +## Lookup Tables |
| 620 | + |
| 621 | +### ACS Column ID to Label |
| 622 | + |
| 623 | +```{python} |
| 624 | +lookup_hhinc = pd.DataFrame({ |
| 625 | + "Income Category": [ |
| 626 | + "HH_LT_10K", "HH_10_15K", "HH_15_20K", "HH_20_25K", "HH_25_30K", "HH_30_35K", |
| 627 | + "HH_35_40K", "HH_40_45K", "HH_45_50K", "HH_50_60K", "HH_60_75K", |
| 628 | + "HH_75_100K", "HH_100_125K", "HH_125_150K", "HH_150_200K", "HH_GT_200K" |
| 629 | + ], |
| 630 | + "Lower Limit": [ |
| 631 | + 0, 10000, 15000, 20000, 25000, 30000, |
| 632 | + 35000, 40000, 45000, 50000, 60000, |
| 633 | + 75000, 100000, 125000, 150000, 200000 |
| 634 | + ], |
| 635 | + "Upper Limit": [ |
| 636 | + 9999, 14999, 19999, 24999, 29999, 34999, |
| 637 | + 39999, 44999, 49999, 59999, 74999, |
| 638 | + 99999, 124999, 149999, 199999, np.inf |
| 639 | + ] |
| 640 | +}) |
| 641 | +
|
| 642 | +# Compute midpoint and round it |
| 643 | +lookup_hhinc['Midpoint'] = ( |
| 644 | + (lookup_hhinc['Lower Limit'] + lookup_hhinc['Upper Limit']) / 2 |
| 645 | +).round() |
| 646 | +
|
| 647 | +# Replace infinite midpoint (last category) with 300000 |
| 648 | +lookup_hhinc.loc[np.isinf(lookup_hhinc["Upper Limit"]), "Midpoint"] = 300000 |
| 649 | +
|
| 650 | +lookup_hhinc |
| 651 | +``` |
| 652 | + |
| 653 | +### BlockGroupID for TAZ Centroid (Use if No HH in TAZ) |
| 654 | + |
| 655 | +```{python} |
| 656 | +
|
| 657 | +``` |
| 658 | + |
659 | 659 | ## Processing |
660 | 660 |
|
661 | 661 |
|
|
0 commit comments