Files
d4c-datapkg-statistical/experiments/presentation/cop_2021_structure_example.ipynb
T

18 KiB

In [1]:
import duckdb
import pandas as pd
In [2]:
con = duckdb.connect()
con.install_extension("spatial")
con.load_extension("spatial")
In [3]:
con.execute("""
DROP TABLE IF EXISTS geo_data;
CREATE TABLE geo_data AS
SELECT * FROM 'https://data-01.dataforcanada.org/processed/statistics_canada/census_of_population/2021/tabular/da_2021.parquet';
""")
Out [3]:
FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))
<duckdb.duckdb.DuckDBPyConnection at 0x7fd222a8fb70>
In [4]:
geo_data = con.sql("SELECT * FROM geo_data").to_df()
In [5]:
geo_data
Out [5]:
da_dguid count_total_1 count_total_4 count_total_5 count_total_6 count_total_7 count_total_8 count_total_9 count_total_10 count_total_11 ... count_women_2622 count_women_2623 count_women_2624 count_women_2625 count_women_2626 count_women_2627 count_women_2628 count_women_2629 count_women_2630 count_women_2631
0 2021S051210010165 500 229 217 1309.9 0.38 500 45 10 20 ... 0 15 25 0 25 20 0 0 0 20
1 2021S051210010166 340 165 146 3563.9 0.10 340 50 15 25 ... 15 0 30 0 30 20 0 0 0 20
2 2021S051210010167 407 201 184 3217.4 0.13 405 45 15 10 ... 10 0 35 0 35 25 0 0 0 25
3 2021S051210010168 523 274 248 2736.8 0.19 525 55 15 15 ... 15 30 35 0 35 25 0 0 0 20
4 2021S051210010169 285 131 123 4305.1 0.07 285 40 10 15 ... 10 10 20 0 20 15 0 0 0 15
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
57931 2021S051262080024 423 166 140 1055.9 0.40 425 90 25 35 ... 15 10 55 0 50 40 0 0 0 40
57932 2021S051262080025 514 162 148 1.8 287.39 515 160 50 55 ... 15 10 90 5 90 65 0 0 0 60
57933 2021S051262080026 868 276 249 3.4 251.60 865 285 100 85 ... 20 15 170 10 160 120 5 5 0 110
57934 2021S051262080027 776 196 169 31.5 24.65 775 300 115 90 ... 20 10 160 0 160 100 0 0 0 100
57935 2021S051262080028 573 143 123 146.9 3.90 575 205 75 75 ... 10 15 105 5 105 70 0 0 0 65

57936 rows × 7432 columns

In [ ]: