This example illustrates how to enrich polygons that are in a dataset with variables from CARTO's Data Observatory.
Note: You'll need CARTO Account credentials to reproduce this example.
from cartoframes.utils import set_log_level
set_log_level('debug')
from cartoframes.auth import set_default_credentials
set_default_credentials()
from geopandas import read_file
census_track = 'http://libs.cartocdn.com/cartoframes/files/census_track.geojson'
census_track_gdf = read_file(census_track)
census_track_gdf.head(3)
OBJECTID | FULLTRACTID | TRACTID | geometry | |
---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... |
1 | 2 | 51013103000 | 103000 | POLYGON ((-77.08558 38.82992, -77.08625 38.828... |
2 | 3 | 51013102902 | 102902 | POLYGON ((-77.09520 38.84499, -77.09442 38.844... |
census_track_gdf = census_track_gdf.head(1)
from cartoframes.data.observatory import Catalog
Catalog().country('usa').category('demographics').geographies
[<Geography.get('ags_q17_4739be4f')>, <Geography.get('expn_grid_a4075de4')>, <Geography.get('mbi_blockgroups_1ab060a')>, <Geography.get('mbi_counties_141b61cd')>, <Geography.get('mbi_county_subd_e8e6ea23')>, <Geography.get('mbi_pc_5_digit_4b1682a6')>, <Geography.get('usct_blockgroup_f45b6b49')>, <Geography.get('usct_cbsa_6c8b51ef')>, <Geography.get('usct_censustract_bc698c5a')>, <Geography.get('usct_congression_b6336b2c')>, <Geography.get('usct_county_ec40c962')>, <Geography.get('usct_county_92f1b5df')>, <Geography.get('usct_place_12d6699f')>, <Geography.get('usct_puma_b859f0fa')>, <Geography.get('usct_schooldistr_515af763')>, <Geography.get('usct_schooldistr_da72a4cb')>, <Geography.get('usct_schooldistr_287be4f7')>, <Geography.get('usct_state_4c8090b5')>, <Geography.get('usct_zcta5_75071016')>]
datasets = Catalog().country('usa').category('demographics').geography('usct_censustract_bc698c5a').datasets
datasets.to_dataframe()
id | slug | name | description | country_id | geography_id | geography_name | geography_description | category_id | category_name | provider_id | provider_name | data_source_id | lang | temporal_aggregation | time_coverage | update_frequency | version | is_public_data | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_d4b2cf03 | 5-yr ACS data at Census Tracts level (2006 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2006-01-01, 2011-01-01) | None | 20062010 | True |
1 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_9ed5d625 | 5-yr ACS data at Census Tracts level (2007 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2007-01-01, 2012-01-01) | None | 20072011 | True |
2 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_858c104e | 5-yr ACS data at Census Tracts level (2008 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2008-01-01, 2013-01-01) | None | 20082012 | True |
3 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_cfeb0968 | 5-yr ACS data at Census Tracts level (2009 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2009-01-01, 2014-01-01) | None | 20092013 | True |
4 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_97c32d1f | 5-yr ACS data at Census Tracts level (2010 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2010-01-01, 2015-01-01) | None | 20102014 | True |
5 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_dda43439 | 5-yr ACS data at Census Tracts level (2011 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2011-01-01, 2016-01-01) | None | 20112015 | True |
6 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_30d1f53 | 5-yr ACS data at Census Tracts level (2012 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2012-01-01, 2017-01-01) | None | 20122016 | True |
7 | carto-do-public-data.usa_acs.demographics_soci... | acs_sociodemogr_496a0675 | 5-yr ACS data at Census Tracts level (2013 - 2... | The American Community Survey (ACS) is an ongo... | usa | carto-do-public-data.usa_carto.geography_usa_c... | None | None | demographics | None | None | None | None | eng | 5yrs | [2013-01-01, 2018-01-01) | None | 20132017 | True |
from cartoframes.data.observatory import Dataset
dataset = Dataset.get('acs_sociodemogr_d4b2cf03')
variables_df = dataset.variables
for variable in variables_df:
print(variable.agg_method, variable.db_type, variable.slug)
AVG FLOAT median_age_1b299936 None STRING geoidsl_52dffc46 None STRING geoidsc_c260e1d7 SUM FLOAT owner_occupied__a242d69b SUM FLOAT bachelors_degre_c97d7ec4 SUM FLOAT bachelors_degre_619dbbbf SUM FLOAT children_ccc14aa2 SUM FLOAT children_in_sin_96bc4ba1 SUM FLOAT employed_inform_cc19ebad SUM FLOAT employed_manufa_4e5264bc SUM FLOAT employed_other__a5acf594 SUM FLOAT employed_public_80ba451f SUM FLOAT employed_retail_3cfcad1f SUM FLOAT employed_scienc_10f6c661 SUM FLOAT employed_transp_66aedbfd SUM FLOAT employed_wholes_dfec4891 SUM FLOAT female_female_h_d11712ea SUM FLOAT four_more_cars_297e8a8a AVG FLOAT gini_index_e8c30f9a SUM FLOAT graduate_profes_ce2840a8 SUM FLOAT three_cars_32e541e7 SUM FLOAT pop_25_64_ce8c2ef0 SUM FLOAT pop_determined__486c4212 SUM FLOAT population_1_ye_dcac6ed6 SUM FLOAT population_3_ye_ca9ce3ea AVG FLOAT poverty_4c2c9ac5 SUM FLOAT sales_office_em_abb972b6 SUM FLOAT some_college_an_23a0fb89 SUM FLOAT pop_15_and_over_1b25d822 SUM FLOAT nonfamily_house_2c17f15c SUM FLOAT family_househol_f2823597 AVG FLOAT median_year_str_b19af9b2 SUM FLOAT rent_under_10_p_211ac215 SUM FLOAT total_pop_a33e39b6 SUM FLOAT two_or_more_rac_1ffad07d SUM FLOAT not_hispanic_po_e7e18ed1 SUM FLOAT commuters_by_pu_424732d2 SUM FLOAT households_284a100f AVG FLOAT median_income_57be5af4 AVG FLOAT income_per_capi_b4d33d67 SUM FLOAT housing_units_8326b884 SUM FLOAT vacant_housing__693f6a2e SUM FLOAT one_parent_fami_1dd05196 SUM FLOAT father_one_pare_25ca6df1 SUM FLOAT aggregate_trave_17822663 SUM FLOAT income_less_100_765da10b SUM FLOAT income_10000_14_95a8a848 SUM FLOAT income_15000_19_81ebbbd1 SUM FLOAT income_20000_24_4beab499 SUM FLOAT income_150000_1_ead90f3e SUM FLOAT income_200000_o_70cb9ea7 SUM FLOAT renter_occupied_c1345262 AVG FLOAT owner_occupied__a9e65f75 AVG FLOAT owner_occupied__1cd53499 AVG FLOAT owner_occupied__6fbe04 SUM FLOAT married_househo_ba272390 SUM FLOAT occupied_housin_1c3f3f66 SUM FLOAT housing_units_r_3ee939f2 SUM FLOAT dwellings_1_uni_58e5d43 SUM FLOAT dwellings_1_uni_8cc7c45d SUM FLOAT dwellings_2_uni_c5cf037c SUM FLOAT dwellings_3_to__ff82fdc3 SUM FLOAT dwellings_5_to__716839e3 SUM FLOAT housing_built_1_7de983ff SUM FLOAT rent_burden_not_da5f7289 SUM FLOAT rent_over_50_pe_ad21c098 SUM FLOAT rent_40_to_50_p_d4c51557 SUM FLOAT rent_35_to_40_p_f5793897 SUM FLOAT rent_30_to_35_p_6eb5d82a SUM FLOAT rent_25_to_30_p_b9cdb27f SUM FLOAT rent_20_to_25_p_2f1f2285 SUM FLOAT rent_15_to_20_p_7fc76db3 SUM FLOAT rent_10_to_15_p_ede02d74 SUM FLOAT male_pop_354090a6 SUM FLOAT female_pop_bcc7b2e6 SUM FLOAT white_pop_c874003d SUM FLOAT black_pop_3865cbdc SUM FLOAT asian_pop_12b4b482 SUM FLOAT hispanic_pop_234f387e SUM FLOAT amerindian_pop_828802fd SUM FLOAT other_race_pop_36c463b6 SUM FLOAT vacant_housing__85c50752 SUM FLOAT vacant_housing__62f68a9b AVG FLOAT median_rent_e817137c AVG FLOAT percent_income__d1ee2cb7 SUM FLOAT million_dollar__ece23260 SUM FLOAT mortgaged_housi_3a77552a SUM FLOAT families_with_y_1e479228 SUM FLOAT two_parent_fami_6d4ac4e8 SUM FLOAT two_parents_in__bb6a383b SUM FLOAT two_parents_fat_ead57f01 SUM FLOAT two_parents_mot_738c0aab SUM FLOAT two_parents_not_792221c SUM FLOAT father_in_labor_196dbc7c SUM FLOAT commute_10_14_m_f54c364d SUM FLOAT commute_15_19_m_34560dc SUM FLOAT commute_20_24_m_2f9397d3 SUM FLOAT commute_25_29_m_d99ac142 SUM FLOAT commute_30_34_m_6626f759 SUM FLOAT commute_45_59_m_11238f8b SUM FLOAT income_25000_29_5fa9a700 SUM FLOAT income_30000_34_b70442e9 SUM FLOAT income_35000_39_a3475170 SUM FLOAT income_40000_44_2c1f8b7a SUM FLOAT income_45000_49_385c98e3 SUM FLOAT income_50000_59_229ba5d7 SUM FLOAT income_60000_74_33d3486b SUM FLOAT income_75000_99_592e3a53 SUM FLOAT income_100000_1_f7c091e2 SUM FLOAT income_125000_1_17868e42 SUM FLOAT dwellings_10_to_78e88389 SUM FLOAT dwellings_20_to_4c69a836 SUM FLOAT dwellings_50_or_abd034b2 SUM FLOAT mobile_homes_20947ee9 SUM FLOAT housing_built_2_874b0fbe SUM FLOAT housing_built_2_1215578e SUM FLOAT male_under_5_2e8459e4 SUM FLOAT male_5_to_9_7552c2ff SUM FLOAT male_10_to_14_7fe0e4e7 SUM FLOAT male_15_to_17_b4d19afa SUM FLOAT male_18_to_19_32bed63d SUM FLOAT male_20_c3c94d9c SUM FLOAT male_21_b4ce7d0a SUM FLOAT male_22_to_24_4ddda1ee SUM FLOAT male_25_to_29_f6cbe3dd SUM FLOAT male_30_to_34_ff38118 SUM FLOAT male_35_to_39_237ad202 SUM FLOAT male_40_to_44_4a771ec6 SUM FLOAT male_45_to_49_66fe4ddc SUM FLOAT male_50_to_54_9fc62f19 SUM FLOAT male_55_to_59_b34f7c03 SUM FLOAT male_60_61_e6858d1b SUM FLOAT male_62_64_3ce6b11f SUM FLOAT male_65_to_66_865235b2 SUM FLOAT male_67_to_69_8172390a SUM FLOAT male_70_to_74_efd54ae6 SUM FLOAT male_75_to_79_c35c19fc SUM FLOAT male_80_to_84_b16d4485 SUM FLOAT male_85_and_ove_64f22713 SUM FLOAT female_under_5_6effa65f SUM FLOAT female_5_to_9_d1a61f15 SUM FLOAT female_10_to_14_2313f51c SUM FLOAT female_15_to_17_e8228b01 SUM FLOAT female_18_to_19_6e4dc7c6 SUM FLOAT female_20_97c0ed05 SUM FLOAT female_21_e0c7dd93 SUM FLOAT female_22_to_24_112eb015 SUM FLOAT female_25_to_29_aa38f226 SUM FLOAT female_30_to_34_530090e3 SUM FLOAT female_35_to_39_7f89c3f9 SUM FLOAT female_40_to_44_16840f3d SUM FLOAT female_45_to_49_3a0d5c27 SUM FLOAT female_50_to_54_c3353ee2 SUM FLOAT female_55_to_59_efbc6df8 SUM FLOAT female_60_to_61_16fd9e4d SUM FLOAT female_62_to_64_f1087beb SUM FLOAT female_65_to_66_daa12449 SUM FLOAT female_67_to_69_dd8128f1 SUM FLOAT female_70_to_74_b3265b1d SUM FLOAT female_75_to_79_9faf0807 SUM FLOAT female_80_to_84_ed9e557e SUM FLOAT female_85_and_o_aa0e3bc8 SUM FLOAT white_including_13a12d2a SUM FLOAT black_including_60df12f SUM FLOAT amerindian_incl_2cc3ddb8 SUM FLOAT households_reti_5455ca9 SUM FLOAT asian_including_5f6cf2a1 SUM FLOAT commute_5_9_min_bfa74847 SUM FLOAT commute_35_39_m_902fa1c8 SUM FLOAT commute_40_44_m_415dd2ae SUM FLOAT commute_60_89_m_3e967b39 SUM FLOAT commute_90_more_cbc109e SUM FLOAT asian_male_45_5_7e082193 SUM FLOAT asian_male_55_6_68455be0 SUM FLOAT black_male_45_5_8c8c15de SUM FLOAT black_male_55_6_9ac16fad SUM FLOAT hispanic_male_4_c3d75b15 SUM FLOAT hispanic_male_5_d59a2166 SUM FLOAT white_male_45_5_8992fe9f SUM FLOAT white_male_55_6_9fdf84ec SUM FLOAT commuters_by_bu_f462d018 SUM FLOAT commuters_by_ca_120481e3 SUM FLOAT commuters_by_ca_59febe6f SUM FLOAT commuters_by_su_4321535d SUM FLOAT commuters_drove_acf77a1 SUM FLOAT different_house_168a8dda SUM FLOAT different_house_307db01c SUM FLOAT employed_agricu_f4fac119 SUM FLOAT employed_arts_e_7f42bf01 SUM FLOAT employed_constr_a28f52 SUM FLOAT employed_educat_958fdcfe SUM FLOAT employed_financ_832aff0 SUM FLOAT group_quarters_f24e7e81 SUM FLOAT high_school_inc_801ba545 SUM FLOAT households_publ_d903e7c5 SUM FLOAT in_grades_1_to__793491e9 SUM FLOAT in_grades_5_to__eb139fd4 SUM FLOAT in_grades_9_to__8de26a62 SUM FLOAT in_school_5d68bd33 SUM FLOAT in_undergrad_co_11ce5095 SUM FLOAT less_than_high__18fc6722 SUM FLOAT male_45_64_asso_be1663b3 SUM FLOAT male_45_64_bach_6b3eabae SUM FLOAT male_45_64_grad_fbd67eb0 SUM FLOAT male_45_64_less_50cc49a5 SUM FLOAT male_45_64_grad_d3f1aec0 SUM FLOAT male_45_64_high_6fa71b7c SUM FLOAT male_45_64_some_dc1e1dff SUM FLOAT male_45_to_64_2a7953e3 SUM FLOAT male_male_house_aa5c9704 SUM FLOAT management_busi_6f59f766 SUM FLOAT no_car_2207f034 SUM FLOAT no_cars_3a983c4e SUM FLOAT not_us_citizen__46c0b5c4 SUM FLOAT occupation_mana_4f052cbd SUM FLOAT occupation_natu_35dc85be SUM FLOAT occupation_prod_4c913f7f SUM FLOAT occupation_sale_e7afd291 SUM FLOAT occupation_serv_a3e87fbe SUM FLOAT one_car_13b3a60b SUM FLOAT two_cars_fec37223 SUM FLOAT walked_to_work_3e52e21c SUM FLOAT worked_at_home_5ff2f52f SUM FLOAT workers_16_and__f5bce7ef SUM FLOAT hispanic_any_ra_319301 SUM FLOAT pop_5_years_ove_2d330bc0 SUM FLOAT speak_only_engl_73f2e1ff SUM FLOAT speak_spanish_a_8aee2c1f SUM FLOAT speak_spanish_a_ce691296 SUM FLOAT pop_never_marri_651528ed SUM FLOAT pop_now_married_ee923870 SUM FLOAT pop_separated_9f2ec8b9 SUM FLOAT pop_widowed_a4b162d6 SUM FLOAT pop_divorced_61aba4d6 None STRING geoid_c6cf8662 None STRING do_date_a1b1496e
from cartoframes.data.observatory import Variable
v1 = Variable.get('no_car_2207f034') # SUM, FLOAT
v2 = Variable.get('poverty_4c2c9ac5') # AVG, FLOAT
v3 = Variable.get('geoidsl_52dffc46') # None, STRING
variables = [v1, v2, v3]
from cartoframes.data.observatory import Enrichment
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation=None
)
2020-03-13 13:18:04,568 - DEBUG - _prepare_data in 0.01 s 2020-03-13 13:18:09,230 - DEBUG - _upload_data in 4.66 s 2020-03-13 13:18:17,120 - DEBUG - _execute_enrichment in 7.89 s 2020-03-13 13:18:17,126 - DEBUG - _enrich in 12.57 s
enriched_dataset_gdf.head(20)
OBJECTID | FULLTRACTID | TRACTID | geometry | geoidsl | poverty | no_car | intersected_area | do_area | user_area | do_geoid | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102802 | 55.0 | 0.0 | 35.033737 | 7.313817e+05 | 681621.693138 | 51013102802 |
1 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102901 | 68.0 | 0.0 | 677561.538702 | 6.961294e+05 | 681621.693138 | 51013102901 |
2 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51510201000 | 100.0 | 14.0 | 23.771227 | 7.811361e+05 | 681621.693138 | 51510201000 |
3 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102902 | 256.0 | 124.0 | 3571.753693 | 7.531163e+05 | 681621.693138 | 51013102902 |
4 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51510200107 | 341.0 | 217.0 | 161.381823 | 6.377265e+05 | 681621.693138 | 51510200107 |
5 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102702 | 247.0 | 61.0 | 0.390070 | 2.834087e+05 | 681621.693138 | 51013102702 |
6 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013103100 | 489.0 | 102.0 | 267.823804 | 1.908856e+06 | 681621.693138 | 51013103100 |
from cartoframes.data.observatory import Enrichment
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation=None,
filters={v1.id: "> 100", v2.id: "< 300"}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:23:45,199 - DEBUG - _prepare_data in 0.01 s 2020-03-13 13:23:48,893 - DEBUG - _upload_data in 3.69 s 2020-03-13 13:23:55,352 - DEBUG - _execute_enrichment in 6.46 s 2020-03-13 13:23:55,360 - DEBUG - _enrich in 10.17 s
OBJECTID | FULLTRACTID | TRACTID | geometry | geoidsl | poverty | no_car | intersected_area | do_area | user_area | do_geoid | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102902 | 256.0 | 124.0 | 3571.753693 | 753116.255091 | 681621.693138 | 51013102902 |
from cartoframes.data.observatory import Enrichment
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables
)
2020-03-13 13:18:17,187 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:18:22,133 - DEBUG - _upload_data in 4.94 s 2020-03-13 13:18:29,719 - DEBUG - _execute_enrichment in 7.59 s 2020-03-13 13:18:29,769 - DEBUG - _enrich in 12.58 s
enriched_dataset_gdf.head(20)
OBJECTID | FULLTRACTID | TRACTID | geometry | poverty | no_car | |
---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 222.285714 | 0.657821 |
from cartoframes.data.observatory import Enrichment
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation='ARRAY_AGG'
)
2020-03-13 13:18:29,843 - DEBUG - _prepare_data in 0.01 s 2020-03-13 13:18:33,361 - DEBUG - _upload_data in 3.52 s 2020-03-13 13:18:41,083 - DEBUG - _execute_enrichment in 7.72 s 2020-03-13 13:18:41,109 - DEBUG - _enrich in 11.28 s
enriched_dataset_gdf.head(20)
OBJECTID | FULLTRACTID | TRACTID | geometry | geoidsl | poverty | no_car | |
---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | ['51013102902', '51013103100', '51510200107', ... | [256.0, 489.0, 341.0, 247.0, 55.0, 68.0, 100.0] | [124.0, 102.0, 217.0, 61.0, 0.0, 0.0, 14.0] |
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation={v1.id: ['SUM', 'AVG'], v2.id:'AVG'}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:18:41,154 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:18:44,561 - DEBUG - _upload_data in 3.41 s 2020-03-13 13:18:50,709 - DEBUG - _execute_enrichment in 6.15 s 2020-03-13 13:18:50,739 - DEBUG - _enrich in 9.59 s
OBJECTID | FULLTRACTID | TRACTID | geometry | poverty | sum_no_car | avg_no_car | |
---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 222.285714 | 0.657821 | 74.0 |
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation=None,
filters={v1.id: "> 0"}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:18:50,770 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:18:54,184 - DEBUG - _upload_data in 3.41 s 2020-03-13 13:19:00,228 - DEBUG - _execute_enrichment in 6.04 s 2020-03-13 13:19:00,237 - DEBUG - _enrich in 9.47 s
OBJECTID | FULLTRACTID | TRACTID | geometry | geoidsl | poverty | no_car | intersected_area | do_area | user_area | do_geoid | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102902 | 256.0 | 124.0 | 3571.753693 | 7.531163e+05 | 681621.693138 | 51013102902 |
1 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102702 | 247.0 | 61.0 | 0.390070 | 2.834087e+05 | 681621.693138 | 51013102702 |
2 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51510201000 | 100.0 | 14.0 | 23.771227 | 7.811361e+05 | 681621.693138 | 51510201000 |
3 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013103100 | 489.0 | 102.0 | 267.823804 | 1.908856e+06 | 681621.693138 | 51013103100 |
4 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51510200107 | 341.0 | 217.0 | 161.381823 | 6.377265e+05 | 681621.693138 | 51510200107 |
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation=None,
filters={v1.id: ["> 0", "< 200"]}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:19:00,296 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:19:05,040 - DEBUG - _upload_data in 4.74 s 2020-03-13 13:19:12,828 - DEBUG - _execute_enrichment in 7.79 s 2020-03-13 13:19:12,852 - DEBUG - _enrich in 12.56 s
OBJECTID | FULLTRACTID | TRACTID | geometry | geoidsl | poverty | no_car | intersected_area | do_area | user_area | do_geoid | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013103100 | 489.0 | 102.0 | 267.823804 | 1.908856e+06 | 681621.693138 | 51013103100 |
1 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102702 | 247.0 | 61.0 | 0.390070 | 2.834087e+05 | 681621.693138 | 51013102702 |
2 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51510201000 | 100.0 | 14.0 | 23.771227 | 7.811361e+05 | 681621.693138 | 51510201000 |
3 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 51013102902 | 256.0 | 124.0 | 3571.753693 | 7.531163e+05 | 681621.693138 | 51013102902 |
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
filters={v1.id: ["> 0", "< 200"]}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:19:12,898 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:19:17,869 - DEBUG - _upload_data in 4.97 s 2020-03-13 13:19:25,423 - DEBUG - _execute_enrichment in 7.55 s 2020-03-13 13:19:25,452 - DEBUG - _enrich in 12.56 s
OBJECTID | FULLTRACTID | TRACTID | geometry | poverty | no_car | |
---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 273.0 | 0.602908 |
enrichment = Enrichment()
enriched_dataset_gdf = enrichment.enrich_polygons(
census_track_gdf,
variables=variables,
aggregation={v1.id: ['SUM', 'AVG'], v2.id:'AVG'},
filters={v1.id: ["> 0", "< 200"]}
)
enriched_dataset_gdf.head(20)
2020-03-13 13:19:25,480 - DEBUG - _prepare_data in 0.0 s 2020-03-13 13:19:28,968 - DEBUG - _upload_data in 3.49 s 2020-03-13 13:19:36,482 - DEBUG - _execute_enrichment in 7.51 s 2020-03-13 13:19:36,507 - DEBUG - _enrich in 11.03 s
OBJECTID | FULLTRACTID | TRACTID | geometry | poverty | sum_no_car | avg_no_car | |
---|---|---|---|---|---|---|---|
0 | 1 | 51013102901 | 102901 | POLYGON ((-77.09099 38.84516, -77.08957 38.844... | 273.0 | 0.602908 | 75.25 |