Download a Dataset

This example illustrates how to download a dataset from CARTO's Data Observatory. As datasets can be really big, we will show you how to apply standard SQL filters and spatial SQL filters to download them.

Note: You'll need CARTO Account credentials to reproduce this example.


In [1]:
from cartoframes.auth import set_default_credentials

set_default_credentials('creds.json')

As datasets may have a lot of columns, let's force pandas to display all the columns


In [2]:
import pandas

pandas.set_option('display.max_columns', None)

Choose a dataset

Learn how to discover a dataset through the catalog by checking the discovery example.

You can also choose a dataset from your subscriptions. Call Catalog().subscriptions() to list your active subscriptions.


In [3]:
from cartoframes.data.observatory import Dataset

dataset = Dataset.get('acs_sociodemogr_8c2655e0')
dataset.to_dict()


Out[3]:
{'slug': 'acs_sociodemogr_8c2655e0',
 'name': 'Sociodemographics - United States of America (County, 2017, 5yrs)',
 'description': 'The American Community Survey (ACS) is an ongoing survey that provides vital information on a yearly basis about the USA and its people. This dataset contains only a subset of the variables that have been deemed most relevant. More info: https://www.census.gov/programs-surveys/acs/about.html',
 'category_id': 'demographics',
 'country_id': 'usa',
 'data_source_id': 'sociodemographics',
 'provider_id': 'usa_acs',
 'geography_name': 'County - United States of America',
 'geography_description': 'Shoreline clipped TIGER/Line boundaries. More info: https://carto.com/blog/tiger-shoreline-clip/',
 'temporal_aggregation': '5yrs',
 'time_coverage': '[2013-01-01, 2018-01-01)',
 'update_frequency': 'yearly',
 'is_public_data': True,
 'lang': 'eng',
 'version': '20132017',
 'category_name': 'Demographics',
 'provider_name': 'American Community Survey',
 'geography_id': 'carto-do-public-data.carto.geography_usa_county_2015',
 'id': 'carto-do-public-data.usa_acs.demographics_sociodemographics_usa_county_2015_5yrs_20132017'}

Call head() to check a sample of the dataset and see the available columns.


In [4]:
dataset.head()


Out[4]:
geoid no_car do_date male_20 male_21 no_cars one_car poverty children male_pop two_cars asian_pop black_pop female_20 female_21 in_school pop_25_64 total_pop white_pop female_pop gini_index households male_60_61 male_62_64 median_age three_cars male_5_to_9 median_rent pop_16_over pop_widowed armed_forces employed_pop hispanic_pop male_under_5 mobile_homes pop_divorced female_5_to_9 housing_units male_10_to_14 male_15_to_17 male_18_to_19 male_22_to_24 male_25_to_29 male_30_to_34 male_35_to_39 male_40_to_44 male_45_to_49 male_45_to_64 male_50_to_54 male_55_to_59 male_65_to_66 male_67_to_69 male_70_to_74 male_75_to_79 male_80_to_84 median_income pop_separated amerindian_pop female_under_5 four_more_cars group_quarters masters_degree other_race_pop unemployed_pop walked_to_work worked_at_home female_10_to_14 female_15_to_17 female_18_to_19 female_22_to_24 female_25_to_29 female_30_to_34 female_35_to_39 female_40_to_44 female_45_to_49 female_50_to_54 female_55_to_59 female_60_to_61 female_62_to_64 female_65_to_66 female_67_to_69 female_70_to_74 female_75_to_79 female_80_to_84 pop_15_and_over pop_now_married asian_male_45_54 asian_male_55_64 bachelors_degree black_male_45_54 black_male_55_64 commute_5_9_mins commuters_by_bus in_grades_1_to_4 in_grades_5_to_8 male_85_and_over not_hispanic_pop pop_5_years_over white_male_45_54 white_male_55_64 associates_degree commuters_16_over dwellings_2_units family_households hispanic_any_race in_grades_9_to_12 income_less_10000 income_per_capita pop_25_years_over pop_never_married bachelors_degree_2 commute_10_14_mins commute_15_19_mins commute_20_24_mins commute_25_29_mins commute_30_34_mins commute_35_39_mins commute_35_44_mins commute_40_44_mins commute_45_59_mins commute_60_89_mins female_85_and_over income_10000_14999 income_15000_19999 income_20000_24999 income_25000_29999 income_30000_34999 income_35000_39999 income_40000_44999 income_45000_49999 income_50000_59999 income_60000_74999 income_75000_99999 married_households not_in_labor_force not_us_citizen_pop pop_in_labor_force high_school_diploma hispanic_male_45_54 hispanic_male_55_64 occupation_services workers_16_and_over civilian_labor_force commute_60_more_mins commute_90_more_mins commute_less_10_mins commuters_by_carpool employed_information in_undergrad_college income_100000_124999 income_125000_149999 income_150000_199999 male_male_households nonfamily_households rent_over_50_percent vacant_housing_units commuters_drove_alone employed_construction employed_retail_trade income_200000_or_more less_one_year_college male_45_64_grade_9_12 one_year_more_college rent_10_to_15_percent rent_15_to_20_percent rent_20_to_25_percent rent_25_to_30_percent rent_30_to_35_percent rent_35_to_40_percent rent_40_to_50_percent rent_under_10_percent sales_office_employed speak_spanish_at_home two_or_more_races_pop dwellings_3_to_4_units dwellings_5_to_9_units employed_manufacturing male_45_64_high_school occupied_housing_units male_45_64_some_college mortgaged_housing_units occupation_sales_office population_3_years_over asian_including_hispanic black_including_hispanic dwellings_10_to_19_units dwellings_20_to_49_units employed_wholesale_trade female_female_households rent_burden_not_computed white_including_hispanic high_school_including_ged commuters_by_car_truck_van dwellings_1_units_attached dwellings_1_units_detached dwellings_50_or_more_units housing_built_2000_to_2004 male_45_64_graduate_degree occupation_management_arts population_1_year_and_over speak_only_english_at_home housing_built_2005_or_later male_45_64_bachelors_degree median_year_structure_built children_in_single_female_hh families_with_young_children graduate_professional_degree households_retirement_income male_45_64_associates_degree male_45_64_less_than_9_grade million_dollar_housing_units owner_occupied_housing_units percent_income_spent_on_rent aggregate_travel_time_to_work amerindian_including_hispanic housing_built_1939_or_earlier housing_units_renter_occupied pop_determined_poverty_status vacant_housing_units_for_rent vacant_housing_units_for_sale employed_public_administration less_than_high_school_graduate commuters_by_subway_or_elevated bachelors_degree_or_higher_25_64 employed_education_health_social speak_spanish_at_home_low_english commuters_by_public_transportation different_house_year_ago_same_city some_college_and_associates_degree households_public_asst_or_food_stamps management_business_sci_arts_employed employed_finance_insurance_real_estate different_house_year_ago_different_city employed_science_management_admin_waste one_parent_families_with_young_children two_parent_families_with_young_children employed_other_services_not_public_admin owner_occupied_housing_units_median_value employed_transportation_warehousing_utilities occupation_production_transportation_material father_one_parent_families_with_young_children owner_occupied_housing_units_lower_value_quartile owner_occupied_housing_units_upper_value_quartile employed_agriculture_forestry_fishing_hunting_mining occupation_natural_resources_construction_maintenance two_parents_in_labor_force_families_with_young_children employed_arts_entertainment_recreation_accommodation_food renter_occupied_housing_units_paying_cash_median_gross_rent two_parents_not_in_labor_force_families_with_young_children father_in_labor_force_one_parent_families_with_young_children two_parents_father_in_labor_force_families_with_young_children two_parents_mother_in_labor_force_families_with_young_children
0 30007 43.0 20132017 32.0 20.0 65.0 463.0 448.0 1151.0 2896.0 887.0 0.0 4.0 0.0 0.0 1017.0 2936.0 5755.0 5432.0 2859.0 0.4452 2405.0 105.0 196.0 46.3 622.0 132.0 550.0 4762.0 None 0.0 2621.0 152.0 112.0 377.0 None 207.0 2743.0 196.0 117.0 75.0 54.0 135.0 131.0 160.0 163.0 184.0 908.0 210.0 213.0 63.0 171.0 191.0 129.0 66.0 55295.0 None 84.0 146.0 368.0 44.0 293.0 0.0 112.0 135.0 205.0 124.0 117.0 123.0 90.0 91.0 113.0 165.0 153.0 218.0 250.0 196.0 116.0 137.0 74.0 114.0 173.0 158.0 52.0 None None 0.0 0.0 866.0 0.0 0.0 359.0 0.0 253.0 252.0 41.0 5603.0 None 369.0 463.0 268.0 2287.0 15.0 1552.0 152.0 336.0 96.0 32268.0 4210.0 None 866.0 337.0 132.0 225.0 159.0 162.0 214.0 247.0 33.0 271.0 150.0 42.0 135.0 96.0 101.0 88.0 84.0 210.0 166.0 76.0 305.0 241.0 267.0 1348.0 2029.0 20.0 2733.0 1366.0 0.0 5.0 461.0 2492.0 2733.0 203.0 53.0 551.0 267.0 31.0 79.0 170.0 82.0 186.0 0.0 853.0 47.0 338.0 1852.0 370.0 180.0 102.0 261.0 24.0 683.0 94.0 22.0 52.0 15.0 45.0 5.0 32.0 6.0 404.0 None 83.0 41.0 49.0 215.0 287.0 2405.0 247.0 1122.0 404.0 5553.0 0.0 4.0 41.0 0.0 42.0 0.0 67.0 5533.0 1564.0 2119.0 0.0 2208.0 0.0 61.0 87.0 955.0 5634.0 None 16.0 158.0 1987.0 147.0 335.0 337.0 625.0 92.0 13.0 26.0 2020.0 23.6 60655.0 84.0 97.0 385.0 5711.0 11.0 34.0 291.0 231.0 0.0 873.0 380.0 None 0.0 32.0 1212.0 179.0 955.0 141.0 471.0 141.0 64.0 271.0 94.0 195000.0 90.0 310.0 0.0 119800.0 301300.0 460.0 491.0 90.0 186.0 640.0 18.0 0.0 163.0 0.0
1 19137 106.0 20132017 17.0 42.0 291.0 1298.0 1653.0 2349.0 4931.0 1826.0 0.0 0.0 42.0 103.0 2094.0 5037.0 10239.0 9640.0 5308.0 0.4270 4614.0 149.0 256.0 44.5 774.0 385.0 482.0 8243.0 None 11.0 4838.0 371.0 259.0 178.0 None 310.0 5231.0 313.0 238.0 115.0 182.0 217.0 239.0 252.0 323.0 301.0 1449.0 366.0 377.0 148.0 162.0 193.0 146.0 137.0 43674.0 None 40.0 335.0 425.0 210.0 227.0 0.0 349.0 194.0 233.0 302.0 207.0 127.0 119.0 220.0 233.0 262.0 345.0 320.0 373.0 452.0 152.0 200.0 126.0 168.0 273.0 233.0 177.0 None None 0.0 0.0 867.0 0.0 0.0 1023.0 21.0 569.0 512.0 114.0 9868.0 None 628.0 782.0 926.0 4560.0 177.0 3080.0 371.0 530.0 282.0 25005.0 7143.0 None 867.0 568.0 487.0 485.0 205.0 236.0 39.0 82.0 43.0 292.0 205.0 229.0 419.0 298.0 345.0 218.0 343.0 211.0 226.0 222.0 433.0 515.0 485.0 2221.0 3045.0 136.0 5198.0 2447.0 39.0 0.0 824.0 4793.0 5187.0 319.0 114.0 1886.0 453.0 153.0 176.0 317.0 121.0 93.0 0.0 1534.0 246.0 617.0 3813.0 309.0 641.0 86.0 716.0 111.0 935.0 180.0 193.0 164.0 144.0 51.0 77.0 168.0 75.0 1081.0 None 188.0 291.0 101.0 870.0 680.0 4614.0 264.0 1552.0 1081.0 9869.0 0.0 0.0 49.0 40.0 120.0 3.0 185.0 9756.0 2785.0 4266.0 77.0 4318.0 0.0 27.0 32.0 1470.0 10138.0 None 5.0 178.0 1952.0 756.0 662.0 281.0 807.0 151.0 33.0 0.0 3131.0 26.3 86680.0 64.0 181.0 1483.0 10014.0 142.0 67.0 122.0 633.0 0.0 856.0 1172.0 None 21.0 550.0 2577.0 831.0 1470.0 170.0 839.0 173.0 327.0 335.0 301.0 81800.0 245.0 949.0 29.0 49500.0 126300.0 349.0 514.0 248.0 213.0 664.0 12.0 25.0 64.0 11.0
2 20101 10.0 20132017 8.0 0.0 36.0 181.0 181.0 407.0 864.0 350.0 0.0 1.0 1.0 8.0 332.0 822.0 1702.0 1539.0 838.0 0.4473 828.0 10.0 27.0 41.5 133.0 26.0 345.0 1379.0 None 0.0 885.0 113.0 74.0 46.0 None 74.0 991.0 46.0 54.0 22.0 45.0 59.0 26.0 76.0 49.0 56.0 226.0 72.0 61.0 19.0 22.0 25.0 40.0 39.0 51765.0 None 39.0 48.0 128.0 8.0 69.0 0.0 32.0 32.0 27.0 47.0 38.0 35.0 13.0 40.0 29.0 48.0 53.0 44.0 45.0 63.0 19.0 45.0 22.0 14.0 40.0 42.0 38.0 None None 0.0 0.0 206.0 0.0 0.0 178.0 0.0 64.0 79.0 8.0 1589.0 None 121.0 96.0 135.0 817.0 0.0 484.0 113.0 67.0 62.0 29768.0 1163.0 None 206.0 98.0 93.0 64.0 38.0 47.0 15.0 15.0 0.0 9.0 35.0 32.0 42.0 50.0 67.0 67.0 35.0 32.0 35.0 12.0 79.0 109.0 139.0 401.0 462.0 12.0 917.0 302.0 6.0 2.0 165.0 844.0 917.0 43.0 8.0 410.0 42.0 10.0 48.0 45.0 11.0 18.0 0.0 344.0 16.0 163.0 732.0 112.0 73.0 25.0 106.0 7.0 207.0 27.0 16.0 18.0 13.0 19.0 8.0 0.0 10.0 185.0 None 3.0 33.0 0.0 6.0 82.0 828.0 61.0 306.0 185.0 1623.0 0.0 1.0 0.0 0.0 13.0 0.0 52.0 1649.0 361.0 774.0 22.0 890.0 0.0 15.0 3.0 264.0 1659.0 None 0.0 48.0 1957.0 43.0 137.0 72.0 107.0 22.0 3.0 0.0 649.0 22.9 NaN 39.0 95.0 179.0 1690.0 28.0 0.0 28.0 76.0 0.0 211.0 196.0 None 0.0 61.0 448.0 61.0 264.0 30.0 84.0 34.0 20.0 117.0 51.0 76400.0 55.0 73.0 13.0 44300.0 124400.0 253.0 198.0 65.0 24.0 551.0 0.0 13.0 48.0 4.0
3 48307 133.0 20132017 1.0 93.0 220.0 883.0 1296.0 1935.0 4171.0 1232.0 0.0 161.0 39.0 14.0 1623.0 4096.0 8145.0 5067.0 3974.0 0.4495 3143.0 240.0 134.0 43.5 510.0 370.0 471.0 6496.0 None 0.0 3658.0 2571.0 327.0 393.0 None 263.0 4302.0 212.0 220.0 33.0 111.0 284.0 236.0 272.0 152.0 206.0 1054.0 310.0 164.0 106.0 111.0 296.0 94.0 139.0 42367.0 None 1.0 154.0 298.0 154.0 213.0 202.0 122.0 104.0 61.0 258.0 131.0 66.0 21.0 340.0 82.0 271.0 321.0 285.0 188.0 273.0 121.0 217.0 147.0 117.0 228.0 156.0 134.0 None None 0.0 0.0 671.0 18.0 0.0 867.0 2.0 483.0 334.0 60.0 5574.0 None 327.0 391.0 217.0 3389.0 229.0 2164.0 2571.0 453.0 228.0 23398.0 5832.0 None 671.0 535.0 412.0 410.0 23.0 202.0 71.0 117.0 46.0 75.0 52.0 148.0 265.0 288.0 127.0 156.0 203.0 207.0 137.0 124.0 259.0 329.0 385.0 1592.0 2716.0 207.0 3780.0 1597.0 164.0 147.0 770.0 3450.0 3780.0 133.0 81.0 1482.0 424.0 17.0 70.0 176.0 114.0 69.0 0.0 979.0 227.0 1159.0 2857.0 171.0 383.0 76.0 500.0 201.0 1092.0 64.0 100.0 59.0 44.0 46.0 25.0 24.0 19.0 809.0 None 143.0 110.0 16.0 214.0 458.0 3143.0 203.0 889.0 809.0 7863.0 0.0 161.0 6.0 18.0 39.0 0.0 137.0 6969.0 1862.0 3281.0 23.0 3498.0 0.0 78.0 17.0 850.0 8140.0 None 39.0 93.0 1969.0 396.0 589.0 261.0 679.0 7.0 75.0 35.0 2398.0 32.0 53750.0 1.0 551.0 745.0 7955.0 31.0 57.0 192.0 1229.0 0.0 556.0 647.0 None 2.0 634.0 1809.0 600.0 850.0 133.0 829.0 231.0 206.0 383.0 363.0 82000.0 401.0 510.0 165.0 41600.0 165300.0 602.0 719.0 214.0 265.0 721.0 0.0 165.0 169.0 0.0
4 46123 66.0 20132017 8.0 21.0 118.0 544.0 1045.0 1237.0 2781.0 649.0 0.0 0.0 9.0 59.0 1121.0 2688.0 5480.0 4500.0 2699.0 0.4633 2424.0 133.0 141.0 46.5 639.0 135.0 341.0 4362.0 None 0.0 2859.0 18.0 140.0 496.0 None 125.0 3085.0 222.0 141.0 50.0 127.0 129.0 143.0 155.0 116.0 164.0 881.0 238.0 205.0 34.0 116.0 112.0 143.0 42.0 48409.0 None 729.0 172.0 474.0 159.0 112.0 0.0 52.0 132.0 223.0 203.0 99.0 46.0 65.0 122.0 123.0 133.0 97.0 173.0 242.0 190.0 108.0 76.0 87.0 84.0 114.0 174.0 55.0 None None 0.0 0.0 643.0 0.0 0.0 878.0 37.0 272.0 269.0 66.0 5462.0 None 310.0 392.0 319.0 2592.0 24.0 1473.0 18.0 273.0 239.0 27613.0 3858.0 None 643.0 347.0 158.0 167.0 120.0 92.0 17.0 56.0 39.0 55.0 143.0 143.0 174.0 110.0 132.0 111.0 119.0 168.0 91.0 124.0 227.0 270.0 279.0 1217.0 1451.0 27.0 2911.0 1367.0 0.0 0.0 393.0 2815.0 2911.0 175.0 32.0 1422.0 247.0 30.0 102.0 226.0 37.0 32.0 0.0 951.0 128.0 661.0 2163.0 271.0 363.0 85.0 196.0 31.0 571.0 87.0 63.0 58.0 79.0 2.0 37.0 104.0 64.0 484.0 None 233.0 108.0 70.0 41.0 387.0 2424.0 140.0 663.0 484.0 5334.0 0.0 0.0 38.0 52.0 75.0 0.0 125.0 4500.0 1511.0 2410.0 16.0 2281.0 0.0 43.0 32.0 1217.0 5425.0 None 19.0 152.0 1966.0 220.0 338.0 210.0 261.0 83.0 56.0 16.0 1677.0 27.5 40040.0 747.0 255.0 747.0 5294.0 95.0 39.0 118.0 408.0 0.0 580.0 674.0 None 37.0 182.0 1086.0 340.0 1217.0 184.0 444.0 92.0 85.0 253.0 139.0 85800.0 52.0 306.0 26.0 51600.0 156600.0 706.0 459.0 215.0 114.0 562.0 0.0 14.0 32.0 6.0
5 29155 308.0 20132017 85.0 189.0 934.0 2639.0 4859.0 4597.0 8210.0 2043.0 0.0 4639.0 197.0 153.0 4301.0 8474.0 17344.0 11948.0 9134.0 0.4862 6875.0 225.0 238.0 37.7 871.0 566.0 344.0 13251.0 None 0.0 6326.0 421.0 614.0 742.0 None 496.0 8178.0 747.0 421.0 226.0 282.0 479.0 431.0 449.0 422.0 526.0 2156.0 567.0 600.0 227.0 234.0 239.0 164.0 153.0 32468.0 None 18.0 671.0 388.0 202.0 483.0 0.0 756.0 153.0 109.0 689.0 393.0 194.0 209.0 573.0 521.0 629.0 452.0 564.0 593.0 715.0 199.0 291.0 159.0 271.0 397.0 291.0 254.0 None None 0.0 0.0 815.0 239.0 230.0 1273.0 23.0 877.0 1260.0 126.0 16923.0 None 824.0 828.0 660.0 6067.0 517.0 4342.0 421.0 1082.0 956.0 18883.0 11212.0 None 815.0 792.0 998.0 913.0 366.0 587.0 78.0 167.0 89.0 181.0 87.0 223.0 689.0 583.0 512.0 504.0 377.0 385.0 382.0 336.0 544.0 392.0 555.0 2758.0 6169.0 97.0 7082.0 3602.0 19.0 19.0 1441.0 6176.0 7082.0 159.0 72.0 1904.0 594.0 26.0 492.0 347.0 96.0 143.0 6.0 2533.0 641.0 1303.0 5259.0 194.0 741.0 74.0 705.0 408.0 1354.0 263.0 285.0 371.0 367.0 188.0 167.0 267.0 155.0 1164.0 None 316.0 513.0 49.0 1328.0 866.0 6875.0 337.0 1652.0 1164.0 16514.0 0.0 4717.0 90.0 16.0 110.0 5.0 540.0 12113.0 4279.0 5853.0 54.0 6098.0 91.0 206.0 25.0 1560.0 17033.0 None 20.0 211.0 1968.0 2120.0 1330.0 532.0 1138.0 58.0 251.0 0.0 3631.0 28.8 105750.0 18.0 853.0 3244.0 17042.0 313.0 89.0 313.0 2867.0 0.0 1066.0 1780.0 None 23.0 1577.0 2719.0 2237.0 1560.0 282.0 1594.0 164.0 813.0 517.0 304.0 73300.0 299.0 1565.0 89.0 37000.0 120900.0 405.0 596.0 216.0 380.0 568.0 2.0 69.0 299.0 0.0
6 21159 28.0 20132017 69.0 89.0 286.0 1464.0 3190.0 2498.0 6744.0 1695.0 0.0 575.0 83.0 64.0 2290.0 6830.0 12175.0 11250.0 5431.0 0.4422 4316.0 213.0 261.0 39.0 645.0 326.0 307.0 9909.0 None 0.0 3032.0 226.0 323.0 1911.0 None 342.0 5240.0 432.0 217.0 125.0 481.0 485.0 720.0 476.0 592.0 430.0 1631.0 433.0 294.0 123.0 142.0 247.0 166.0 61.0 29239.0 None 9.0 295.0 226.0 1441.0 225.0 0.0 552.0 34.0 8.0 334.0 229.0 101.0 118.0 303.0 308.0 384.0 316.0 401.0 419.0 466.0 74.0 255.0 158.0 176.0 203.0 158.0 150.0 None None 0.0 0.0 373.0 159.0 17.0 195.0 0.0 554.0 575.0 39.0 11949.0 None 657.0 726.0 728.0 2791.0 36.0 2940.0 226.0 481.0 782.0 14914.0 8547.0 None 373.0 117.0 575.0 297.0 111.0 235.0 220.0 384.0 164.0 358.0 325.0 94.0 288.0 476.0 430.0 203.0 138.0 224.0 365.0 182.0 271.0 373.0 356.0 2311.0 6325.0 34.0 3584.0 2353.0 33.0 17.0 428.0 2799.0 3584.0 447.0 122.0 267.0 460.0 30.0 292.0 120.0 50.0 58.0 0.0 1376.0 267.0 924.0 2292.0 197.0 520.0 0.0 360.0 347.0 1107.0 109.0 22.0 83.0 98.0 107.0 49.0 35.0 71.0 894.0 None 107.0 53.0 105.0 45.0 736.0 4316.0 218.0 958.0 894.0 11860.0 0.0 606.0 28.0 18.0 88.0 0.0 361.0 11397.0 3313.0 2752.0 37.0 2976.0 54.0 143.0 41.0 875.0 12072.0 None 55.0 19.0 1985.0 473.0 787.0 327.0 987.0 117.0 153.0 0.0 3114.0 31.8 98955.0 9.0 141.0 1202.0 10690.0 63.0 38.0 164.0 2339.0 0.0 553.0 775.0 None 0.0 74.0 2195.0 1218.0 875.0 162.0 1449.0 85.0 184.0 603.0 183.0 65500.0 165.0 319.0 24.0 30000.0 117600.0 392.0 516.0 275.0 226.0 483.0 78.0 24.0 211.0 39.0
7 31005 0.0 20132017 0.0 8.0 0.0 35.0 46.0 132.0 204.0 46.0 0.0 0.0 1.0 1.0 149.0 172.0 421.0 411.0 217.0 0.4498 177.0 9.0 3.0 43.3 54.0 27.0 388.0 298.0 None 0.0 177.0 0.0 3.0 22.0 None 21.0 261.0 20.0 4.0 2.0 13.0 8.0 1.0 6.0 18.0 17.0 50.0 8.0 13.0 2.0 5.0 8.0 10.0 17.0 41250.0 None 0.0 8.0 42.0 0.0 15.0 1.0 1.0 13.0 23.0 35.0 14.0 0.0 0.0 6.0 7.0 5.0 13.0 14.0 11.0 25.0 3.0 5.0 9.0 3.0 10.0 15.0 10.0 None None 0.0 0.0 60.0 0.0 0.0 16.0 0.0 32.0 48.0 2.0 421.0 None 24.0 25.0 33.0 146.0 0.0 96.0 0.0 18.0 6.0 21799.0 264.0 None 60.0 9.0 3.0 16.0 4.0 12.0 3.0 17.0 14.0 15.0 3.0 1.0 21.0 25.0 13.0 4.0 9.0 8.0 12.0 10.0 14.0 22.0 20.0 87.0 120.0 2.0 178.0 73.0 0.0 0.0 17.0 169.0 178.0 6.0 3.0 64.0 24.0 1.0 17.0 7.0 1.0 2.0 0.0 81.0 8.0 84.0 109.0 15.0 13.0 3.0 26.0 0.0 34.0 13.0 3.0 1.0 3.0 2.0 5.0 0.0 0.0 20.0 None 9.0 0.0 0.0 13.0 21.0 177.0 7.0 25.0 20.0 415.0 0.0 0.0 0.0 0.0 3.0 0.0 30.0 411.0 79.0 133.0 10.0 229.0 0.0 3.0 1.0 83.0 421.0 None 0.0 6.0 1959.0 3.0 27.0 19.0 23.0 15.0 0.0 0.0 112.0 25.8 3040.0 0.0 31.0 65.0 421.0 2.0 0.0 3.0 13.0 0.0 59.0 37.0 None 0.0 1.0 93.0 6.0 83.0 1.0 54.0 3.0 2.0 25.0 6.0 101500.0 9.0 21.0 2.0 57000.0 162500.0 67.0 36.0 13.0 6.0 658.0 0.0 2.0 12.0 0.0
8 01067 205.0 20132017 124.0 74.0 427.0 1953.0 2310.0 3581.0 8208.0 2346.0 0.0 4762.0 33.0 120.0 3517.0 8535.0 17110.0 11757.0 8902.0 0.4529 6727.0 176.0 317.0 43.5 1373.0 459.0 398.0 13972.0 None 10.0 6949.0 435.0 468.0 2311.0 None 438.0 9055.0 594.0 307.0 171.0 396.0 369.0 350.0 658.0 418.0 528.0 2232.0 536.0 675.0 252.0 324.0 452.0 293.0 121.0 45569.0 None 5.0 452.0 628.0 289.0 835.0 0.0 496.0 48.0 176.0 511.0 352.0 162.0 326.0 415.0 465.0 527.0 598.0 547.0 617.0 586.0 222.0 531.0 166.0 404.0 567.0 353.0 222.0 None None 0.0 0.0 1087.0 291.0 314.0 605.0 0.0 750.0 892.0 146.0 16675.0 None 757.0 839.0 925.0 6689.0 291.0 4545.0 435.0 844.0 552.0 23983.0 12123.0 None 1087.0 694.0 858.0 1025.0 749.0 1067.0 154.0 395.0 241.0 445.0 301.0 288.0 504.0 566.0 332.0 278.0 457.0 308.0 323.0 412.0 616.0 694.0 614.0 3625.0 6517.0 169.0 7455.0 3398.0 13.0 0.0 1319.0 6865.0 7445.0 431.0 130.0 1025.0 513.0 74.0 595.0 379.0 287.0 257.0 10.0 2182.0 185.0 2328.0 5900.0 386.0 769.0 148.0 828.0 237.0 1843.0 149.0 96.0 162.0 91.0 35.0 109.0 75.0 51.0 1347.0 None 151.0 163.0 0.0 787.0 918.0 6727.0 540.0 2932.0 1347.0 16615.0 0.0 4762.0 52.0 12.0 221.0 0.0 243.0 12144.0 4105.0 6413.0 41.0 6183.0 2.0 218.0 113.0 2279.0 16964.0 None 102.0 153.0 1983.0 761.0 1033.0 987.0 1480.0 175.0 96.0 0.0 5531.0 26.0 171195.0 5.0 343.0 1196.0 16806.0 222.0 164.0 196.0 2348.0 0.0 1485.0 1673.0 None 0.0 378.0 3596.0 1129.0 2279.0 279.0 983.0 495.0 394.0 639.0 231.0 112600.0 788.0 1238.0 89.0 62700.0 189100.0 353.0 766.0 386.0 697.0 603.0 8.0 80.0 245.0 0.0
9 41021 4.0 20132017 19.0 16.0 25.0 176.0 188.0 426.0 962.0 330.0 0.0 0.0 0.0 14.0 396.0 893.0 1910.0 1643.0 948.0 0.4153 805.0 28.0 61.0 47.0 191.0 79.0 537.0 1529.0 None 0.0 751.0 154.0 51.0 146.0 None 51.0 1070.0 51.0 44.0 22.0 13.0 18.0 49.0 41.0 32.0 51.0 283.0 86.0 57.0 47.0 29.0 77.0 48.0 29.0 39831.0 None 99.0 54.0 83.0 15.0 64.0 0.0 61.0 64.0 55.0 64.0 32.0 1.0 26.0 44.0 58.0 49.0 49.0 69.0 31.0 65.0 61.0 44.0 22.0 32.0 62.0 44.0 22.0 None None 0.0 0.0 200.0 0.0 0.0 191.0 0.0 102.0 101.0 14.0 1756.0 None 114.0 130.0 77.0 684.0 15.0 512.0 154.0 96.0 52.0 24178.0 1373.0 None 200.0 101.0 81.0 24.0 18.0 34.0 0.0 20.0 20.0 41.0 5.0 54.0 50.0 20.0 73.0 56.0 77.0 77.0 20.0 52.0 50.0 77.0 90.0 420.0 717.0 30.0 812.0 426.0 11.0 0.0 113.0 739.0 812.0 24.0 19.0 341.0 37.0 14.0 26.0 80.0 20.0 2.0 0.0 293.0 26.0 265.0 575.0 74.0 57.0 9.0 90.0 14.0 297.0 32.0 46.0 8.0 34.0 26.0 15.0 13.0 22.0 156.0 None 0.0 6.0 6.0 22.0 111.0 805.0 85.0 257.0 156.0 1870.0 0.0 0.0 0.0 21.0 20.0 0.0 68.0 1783.0 493.0 612.0 7.0 863.0 6.0 12.0 15.0 233.0 1903.0 None 15.0 40.0 1957.0 109.0 128.0 64.0 169.0 5.0 13.0 0.0 515.0 25.4 11965.0 99.0 73.0 290.0 1906.0 22.0 38.0 62.0 152.0 0.0 194.0 121.0 None 0.0 108.0 464.0 99.0 233.0 11.0 114.0 89.0 49.0 79.0 17.0 110900.0 96.0 126.0 21.0 83300.0 162900.0 96.0 123.0 10.0 72.0 814.0 0.0 21.0 67.0 2.0

Apply a standard filter when downloading the dataset

Let's say we are interested in the children variable to know the number of children per county, we can download just that variable and the geometry and visualise the result in a map.


In [5]:
dataset_df = dataset.to_dataframe(sql_query="select children, geom from $dataset$")

In [6]:
from cartoframes.viz import Map, Layer, color_bins_style

Map(
    Layer(dataset_df, color_bins_style('children'), geom_col='geom'),
    show_info=True,
    viewport={'zoom': 3.17, 'lat': 38.170209, 'lng': -102.736148}
)


Out[6]:
:
StackTrace
    ">

    Apply a spatial filter when downloading the dataset

    Now, instead of downloading just one field, let's download all of them but for a smaller region using a spatial filter. We will use a bounding box for this and you can calculate yours from here: http://bboxfinder.com.

    
    
    In [7]:
    sql_query = "SELECT * FROM $dataset$ WHERE ST_IntersectsBox(geom, -95.031738, 32.082575, -84.616699, 39.537940)"
    dataset_df = dataset.to_dataframe(sql_query=sql_query)
    dataset_df.head(3)
    
    
    
    
    Out[7]:
    geoid do_date total_pop households male_pop female_pop median_age male_under_5 male_5_to_9 male_10_to_14 male_15_to_17 male_18_to_19 male_20 male_21 male_22_to_24 male_25_to_29 male_30_to_34 male_35_to_39 male_40_to_44 male_45_to_49 male_50_to_54 male_55_to_59 male_60_to_61 male_62_to_64 male_65_to_66 male_67_to_69 male_70_to_74 male_75_to_79 male_80_to_84 male_85_and_over female_under_5 female_5_to_9 female_10_to_14 female_15_to_17 female_18_to_19 female_20 female_21 female_22_to_24 female_25_to_29 female_30_to_34 female_35_to_39 female_40_to_44 female_45_to_49 female_50_to_54 female_55_to_59 female_60_to_61 female_62_to_64 female_65_to_66 female_67_to_69 female_70_to_74 female_75_to_79 female_80_to_84 female_85_and_over white_pop population_1_year_and_over population_3_years_over pop_5_years_over pop_15_and_over pop_16_over pop_25_years_over pop_25_64 pop_never_married pop_now_married pop_separated pop_widowed pop_divorced not_us_citizen_pop black_pop asian_pop hispanic_pop amerindian_pop other_race_pop two_or_more_races_pop white_including_hispanic black_including_hispanic asian_including_hispanic amerindian_including_hispanic hispanic_any_race not_hispanic_pop asian_male_45_54 asian_male_55_64 black_male_45_54 black_male_55_64 hispanic_male_45_54 hispanic_male_55_64 white_male_45_54 white_male_55_64 median_income income_per_capita income_less_10000 income_10000_14999 income_15000_19999 income_20000_24999 income_25000_29999 income_30000_34999 income_35000_39999 income_40000_44999 income_45000_49999 income_50000_59999 income_60000_74999 income_75000_99999 income_100000_124999 income_125000_149999 income_150000_199999 income_200000_or_more households_retirement_income pop_determined_poverty_status poverty gini_index housing_units renter_occupied_housing_units_paying_cash_median_gross_rent owner_occupied_housing_units_lower_value_quartile owner_occupied_housing_units_median_value owner_occupied_housing_units_upper_value_quartile occupied_housing_units housing_units_renter_occupied vacant_housing_units vacant_housing_units_for_rent vacant_housing_units_for_sale dwellings_1_units_detached dwellings_1_units_attached dwellings_2_units dwellings_3_to_4_units dwellings_5_to_9_units dwellings_10_to_19_units dwellings_20_to_49_units dwellings_50_or_more_units mobile_homes housing_built_2005_or_later housing_built_2000_to_2004 housing_built_1939_or_earlier median_year_structure_built married_households nonfamily_households family_households households_public_asst_or_food_stamps male_male_households female_female_households children children_in_single_female_hh median_rent percent_income_spent_on_rent rent_burden_not_computed rent_over_50_percent rent_40_to_50_percent rent_35_to_40_percent rent_30_to_35_percent rent_25_to_30_percent rent_20_to_25_percent rent_15_to_20_percent rent_10_to_15_percent rent_under_10_percent owner_occupied_housing_units million_dollar_housing_units mortgaged_housing_units different_house_year_ago_different_city different_house_year_ago_same_city families_with_young_children two_parent_families_with_young_children two_parents_in_labor_force_families_with_young_children two_parents_father_in_labor_force_families_with_young_children two_parents_mother_in_labor_force_families_with_young_children two_parents_not_in_labor_force_families_with_young_children one_parent_families_with_young_children father_one_parent_families_with_young_children father_in_labor_force_one_parent_families_with_young_children commute_5_9_mins commute_less_10_mins commute_10_14_mins commute_15_19_mins commute_20_24_mins commute_25_29_mins commute_30_34_mins commute_35_39_mins commute_40_44_mins commute_35_44_mins commute_45_59_mins commute_60_more_mins commute_60_89_mins commute_90_more_mins commuters_16_over walked_to_work worked_at_home no_car no_cars one_car two_cars three_cars four_more_cars aggregate_travel_time_to_work commuters_by_public_transportation commuters_by_bus commuters_by_car_truck_van commuters_by_carpool commuters_by_subway_or_elevated commuters_drove_alone group_quarters associates_degree bachelors_degree high_school_diploma less_one_year_college masters_degree one_year_more_college less_than_high_school_graduate high_school_including_ged bachelors_degree_2 bachelors_degree_or_higher_25_64 graduate_professional_degree some_college_and_associates_degree male_45_64_associates_degree male_45_64_bachelors_degree male_45_64_graduate_degree male_45_64_less_than_9_grade male_45_64_grade_9_12 male_45_64_high_school male_45_64_some_college male_45_to_64 employed_pop unemployed_pop pop_in_labor_force not_in_labor_force workers_16_and_over armed_forces civilian_labor_force employed_agriculture_forestry_fishing_hunting_mining employed_arts_entertainment_recreation_accommodation_food employed_construction employed_education_health_social employed_finance_insurance_real_estate employed_information employed_manufacturing employed_other_services_not_public_admin employed_public_administration employed_retail_trade employed_science_management_admin_waste employed_transportation_warehousing_utilities employed_wholesale_trade occupation_management_arts occupation_natural_resources_construction_maintenance occupation_production_transportation_material occupation_sales_office occupation_services management_business_sci_arts_employed sales_office_employed in_grades_1_to_4 in_grades_5_to_8 in_grades_9_to_12 in_school in_undergrad_college speak_only_english_at_home speak_spanish_at_home speak_spanish_at_home_low_english do_label do_area do_perimeter do_num_vertices geom
    0 18025 2013-01-01 10598.0 4007.0 5355.0 5243.0 43.7 283.0 369.0 309.0 235.0 142.0 11.0 41.0 205.0 282.0 301.0 284.0 341.0 355.0 417.0 438.0 163.0 259.0 243.0 171.0 194.0 145.0 100.0 67.0 278.0 353.0 326.0 192.0 94.0 54.0 42.0 191.0 256.0 276.0 307.0 328.0 318.0 415.0 462.0 160.0 176.0 131.0 192.0 264.0 134.0 182.0 112.0 10214.0 10469.0 10216.0 NaN NaN 8559.0 7473.0 5538.0 NaN NaN NaN NaN NaN 6.0 21.0 0.0 154.0 63.0 0.0 146.0 10309.0 21.0 14.0 87.0 154.0 10444.0 0.0 7.0 2.0 0.0 9.0 7.0 757.0 834.0 40067.0 19424.0 360.0 286.0 314.0 362.0 179.0 316.0 183.0 189.0 189.0 404.0 524.0 395.0 160.0 76.0 60.0 10.0 819.0 10412.0 1851.0 0.3975 5543.0 562.0 51400.0 86700.0 146100.0 4007.0 673.0 1536.0 67.0 0.0 4190.0 19.0 30.0 30.0 60.0 14.0 66.0 0.0 1094.0 2.0 68.0 210.0 1985.0 2069.0 1297.0 2710.0 625.0 0.0 2.0 2345.0 484.0 348.0 30.1 164.0 116.0 72.0 26.0 41.0 75.0 77.0 50.0 38.0 14.0 3334.0 7.0 1764.0 704.0 98.0 615.0 492.0 287.0 196.0 0.0 9.0 123.0 54.0 48.0 309.0 475.0 362.0 374.0 401.0 216.0 660.0 143.0 140.0 283.0 670.0 647.0 530.0 117.0 4088.0 44.0 107.0 47.0 179.0 1004.0 1405.0 957.0 462.0 133665.0 13.0 13.0 3987.0 310.0 0.0 3677.0 102.0 502.0 486.0 2782.0 434.0 226.0 861.0 1354.0 3543.0 486.0 532.0 293.0 1797.0 114.0 102.0 57.0 110.0 241.0 832.0 176.0 1632.0 4241.0 191.0 4439.0 4120.0 4195.0 7.0 4432.0 127.0 391.0 275.0 873.0 139.0 79.0 1071.0 116.0 204.0 448.0 226.0 264.0 28.0 912.0 493.0 1246.0 712.0 878.0 912.0 712.0 626.0 492.0 617.0 2321.0 306.0 NaN NaN NaN Crawford 7.998498e+08 150379.205 38 POLYGON((-86.679511 38.263086, -86.570136 38.2...
    1 1091 2013-01-01 19743.0 7975.0 9235.0 10508.0 42.1 514.0 601.0 660.0 421.0 236.0 133.0 117.0 307.0 635.0 487.0 529.0 506.0 569.0 628.0 728.0 212.0 358.0 242.0 234.0 475.0 372.0 215.0 56.0 681.0 503.0 755.0 399.0 366.0 177.0 82.0 234.0 600.0 561.0 566.0 661.0 667.0 717.0 579.0 396.0 470.0 266.0 361.0 459.0 439.0 347.0 222.0 8909.0 19541.0 19169.0 NaN NaN 15822.0 13557.0 9869.0 NaN NaN NaN NaN NaN 78.0 10689.0 0.0 88.0 11.0 9.0 37.0 8954.0 10689.0 0.0 11.0 88.0 19655.0 0.0 0.0 583.0 650.0 0.0 0.0 605.0 648.0 32255.0 22996.0 1429.0 656.0 701.0 580.0 451.0 468.0 258.0 335.0 310.0 412.0 713.0 663.0 321.0 272.0 301.0 105.0 1763.0 19502.0 5000.0 0.5303 10307.0 552.0 40700.0 88100.0 172700.0 7975.0 2286.0 2332.0 98.0 86.0 6806.0 64.0 109.0 183.0 494.0 105.0 43.0 9.0 2472.0 83.0 128.0 715.0 1979.0 3102.0 3358.0 4617.0 1971.0 0.0 1.0 4534.0 1909.0 349.0 29.9 706.0 349.0 195.0 67.0 176.0 189.0 99.0 212.0 133.0 160.0 5689.0 5.0 2383.0 985.0 734.0 1398.0 572.0 268.0 168.0 56.0 80.0 826.0 122.0 122.0 1043.0 1643.0 698.0 695.0 822.0 397.0 749.0 143.0 144.0 287.0 377.0 690.0 433.0 257.0 6358.0 81.0 184.0 297.0 922.0 3037.0 2720.0 783.0 513.0 161900.0 0.0 0.0 6126.0 371.0 0.0 5755.0 233.0 1084.0 1315.0 4881.0 800.0 611.0 1930.0 2279.0 5375.0 1315.0 1665.0 774.0 3814.0 277.0 366.0 126.0 86.0 351.0 993.0 296.0 2495.0 6645.0 975.0 7620.0 8202.0 6542.0 0.0 7620.0 249.0 371.0 266.0 1606.0 278.0 107.0 1144.0 376.0 295.0 916.0 340.0 607.0 90.0 1970.0 760.0 1386.0 1361.0 1168.0 1970.0 1361.0 918.0 1229.0 1185.0 4829.0 811.0 NaN NaN NaN Marengo 2.550527e+09 252631.606 68 POLYGON((-87.967893 32.298249, -87.975667 32.3...
    2 5003 2013-01-01 20771.0 8182.0 10126.0 10645.0 41.8 536.0 865.0 713.0 478.0 269.0 80.0 79.0 577.0 429.0 560.0 599.0 513.0 622.0 692.0 807.0 306.0 260.0 438.0 289.0 350.0 346.0 164.0 154.0 578.0 834.0 482.0 333.0 209.0 82.0 51.0 439.0 611.0 511.0 767.0 634.0 759.0 813.0 755.0 235.0 415.0 284.0 303.0 626.0 447.0 223.0 254.0 14126.0 20622.0 20198.0 NaN NaN 16422.0 14166.0 10288.0 NaN NaN NaN NaN NaN 416.0 5309.0 0.0 1083.0 49.0 31.0 173.0 14939.0 5309.0 0.0 49.0 1083.0 19688.0 0.0 0.0 341.0 352.0 23.0 28.0 950.0 993.0 36407.0 20703.0 857.0 784.0 637.0 498.0 503.0 637.0 560.0 369.0 283.0 527.0 646.0 872.0 542.0 178.0 164.0 125.0 1722.0 20552.0 4368.0 0.4658 10152.0 608.0 38900.0 68200.0 115200.0 8182.0 2128.0 1970.0 376.0 136.0 7052.0 56.0 229.0 12.0 190.0 34.0 82.0 41.0 2446.0 66.0 208.0 480.0 1976.0 4163.0 2622.0 5560.0 1651.0 0.0 0.0 4819.0 1436.0 393.0 34.2 357.0 534.0 216.0 118.0 109.0 247.0 169.0 235.0 57.0 86.0 6054.0 6.0 2373.0 1188.0 494.0 1186.0 823.0 351.0 450.0 22.0 0.0 363.0 22.0 22.0 1807.0 2364.0 1463.0 1102.0 722.0 341.0 524.0 18.0 144.0 162.0 400.0 578.0 348.0 230.0 7656.0 178.0 126.0 248.0 542.0 2795.0 2854.0 1490.0 501.0 156480.0 19.0 19.0 7226.0 607.0 0.0 6619.0 193.0 704.0 1333.0 5003.0 786.0 462.0 2485.0 2409.0 5883.0 1333.0 1483.0 566.0 3975.0 135.0 219.0 52.0 77.0 391.0 1158.0 655.0 2687.0 7905.0 870.0 8775.0 7647.0 7782.0 0.0 8775.0 640.0 287.0 722.0 2045.0 176.0 47.0 1407.0 244.0 418.0 951.0 329.0 539.0 100.0 2176.0 1086.0 1820.0 1494.0 1329.0 2176.0 1494.0 1344.0 1124.0 1022.0 5037.0 801.0 NaN NaN NaN Ashley 2.432888e+09 212505.748 37 POLYGON((-91.561673 33.391561, -91.60694 33.39...
    
    
    In [8]:
    Layer(dataset_df, color_bins_style('children'), geom_col='geom')
    
    
    
    
    Out[8]:
    :
    StackTrace