cassiebuhler commited on
Commit
b1c508f
1 Parent(s): b8c83d8

adding municipals

Browse files
Files changed (1) hide show
  1. get_party.ipynb +359 -20
get_party.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "id": "d179ded1-6235-47ed-bbfb-6d72468188d5",
7
  "metadata": {},
8
  "outputs": [],
@@ -20,12 +20,41 @@
20
  "votes = conn.read_parquet(\"vote.parquet\")"
21
  ]
22
  },
 
 
 
 
 
 
 
 
23
  {
24
  "cell_type": "code",
25
- "execution_count": null,
26
  "id": "ab644102-c725-4cf4-915c-8550a0a74c32",
27
  "metadata": {},
28
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  "source": [
30
  "filtered = county.filter((_.mode == \"TOTAL\") & (_.totalvotes > 0))\n",
31
  "\n",
@@ -73,14 +102,14 @@
73
  },
74
  {
75
  "cell_type": "code",
76
- "execution_count": null,
77
  "id": "ce0d80bf-3b78-4aa9-8048-5cc0dbf970d9",
78
  "metadata": {},
79
  "outputs": [],
80
  "source": [
81
  "df = (votes\n",
82
  " .mutate(key = _.key.upper())\n",
83
- " .filter(_.jurisdiction == \"County\")\n",
84
  " .join(county_parties, [\"key\",\"year\"],how='inner'\n",
85
  " )\n",
86
  " .cast({\"geometry\": \"geometry\"})\n",
@@ -89,10 +118,21 @@
89
  },
90
  {
91
  "cell_type": "code",
92
- "execution_count": null,
93
  "id": "87bef5e2-a40a-4aff-aa27-e7d49ec68aac",
94
  "metadata": {},
95
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
96
  "source": [
97
  "import subprocess\n",
98
  "import os\n",
@@ -137,7 +177,7 @@
137
  },
138
  {
139
  "cell_type": "code",
140
- "execution_count": null,
141
  "id": "b086e76c-4285-4036-8033-e4e45cb6966b",
142
  "metadata": {},
143
  "outputs": [],
@@ -145,24 +185,22 @@
145
  "gdf= df.execute()\n",
146
  "gdf = gdf.set_crs(\"EPSG:4326\")\n",
147
  "\n",
148
- "gdf.to_parquet(\"county_parties.parquet\")\n",
149
- "hf_upload(\"county_parties.parquet\", \"boettiger-lab/landvote\")\n",
150
  "\n",
151
- "gdf.to_file(\"county_parties.geojson\")\n",
152
- "hf_upload(\"county_parties.geojson\", \"boettiger-lab/landvote\")\n",
153
  "\n",
154
- "generate_pmtiles(\"county_parties.geojson\", \"county_parties.pmtiles\")\n",
155
- "hf_upload(\"county_parties.pmtiles\", \"boettiger-lab/landvote\")\n"
156
  ]
157
  },
158
  {
159
- "cell_type": "code",
160
- "execution_count": null,
161
- "id": "cb790ed9-6cb8-4705-abaa-ce0008851a87",
162
  "metadata": {},
163
- "outputs": [],
164
  "source": [
165
- "gdf"
166
  ]
167
  },
168
  {
@@ -217,10 +255,311 @@
217
  "m\n"
218
  ]
219
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  {
221
  "cell_type": "code",
222
  "execution_count": null,
223
- "id": "e4280fb7-449a-4a1d-b760-67ce68fb5d92",
224
  "metadata": {},
225
  "outputs": [],
226
  "source": []
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 11,
6
  "id": "d179ded1-6235-47ed-bbfb-6d72468188d5",
7
  "metadata": {},
8
  "outputs": [],
 
20
  "votes = conn.read_parquet(\"vote.parquet\")"
21
  ]
22
  },
23
+ {
24
+ "cell_type": "markdown",
25
+ "id": "170ba045-8848-4a99-a4f6-68bde22428af",
26
+ "metadata": {},
27
+ "source": [
28
+ "# Getting party affiliations for counties"
29
+ ]
30
+ },
31
  {
32
  "cell_type": "code",
33
+ "execution_count": 12,
34
  "id": "ab644102-c725-4cf4-915c-8550a0a74c32",
35
  "metadata": {},
36
+ "outputs": [
37
+ {
38
+ "name": "stdout",
39
+ "output_type": "stream",
40
+ "text": [
41
+ " year key current_party previous_party\n",
42
+ "0 2004 AUTAUGA COUNTY-AL REPUBLICAN REPUBLICAN\n",
43
+ "1 2004 COVINGTON COUNTY-AL REPUBLICAN REPUBLICAN\n",
44
+ "2 2004 ELMORE COUNTY-AL REPUBLICAN REPUBLICAN\n",
45
+ "3 2004 HENRY COUNTY-AL REPUBLICAN REPUBLICAN\n",
46
+ "4 2004 LOWNDES COUNTY-AL DEMOCRAT DEMOCRAT\n",
47
+ "... ... ... ... ...\n",
48
+ "14904 2020 ELK COUNTY-PA REPUBLICAN REPUBLICAN\n",
49
+ "14905 2020 LOVING COUNTY-TX REPUBLICAN REPUBLICAN\n",
50
+ "14906 2020 RED RIVER COUNTY-TX REPUBLICAN REPUBLICAN\n",
51
+ "14907 2020 WHATCOM COUNTY-WA DEMOCRAT DEMOCRAT\n",
52
+ "14908 2020 DISTRICT 12 COUNTY-AK REPUBLICAN REPUBLICAN\n",
53
+ "\n",
54
+ "[14909 rows x 4 columns]\n"
55
+ ]
56
+ }
57
+ ],
58
  "source": [
59
  "filtered = county.filter((_.mode == \"TOTAL\") & (_.totalvotes > 0))\n",
60
  "\n",
 
102
  },
103
  {
104
  "cell_type": "code",
105
+ "execution_count": 13,
106
  "id": "ce0d80bf-3b78-4aa9-8048-5cc0dbf970d9",
107
  "metadata": {},
108
  "outputs": [],
109
  "source": [
110
  "df = (votes\n",
111
  " .mutate(key = _.key.upper())\n",
112
+ " .filter(_.jurisdiction == \"Municipal\")\n",
113
  " .join(county_parties, [\"key\",\"year\"],how='inner'\n",
114
  " )\n",
115
  " .cast({\"geometry\": \"geometry\"})\n",
 
118
  },
119
  {
120
  "cell_type": "code",
121
+ "execution_count": 14,
122
  "id": "87bef5e2-a40a-4aff-aa27-e7d49ec68aac",
123
  "metadata": {},
124
+ "outputs": [
125
+ {
126
+ "name": "stdout",
127
+ "output_type": "stream",
128
+ "text": [
129
+ "The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.\n",
130
+ "Token is valid (permission: write).\n",
131
+ "Your token has been saved to /home/rstudio/.cache/huggingface/token\n",
132
+ "Login successful\n"
133
+ ]
134
+ }
135
+ ],
136
  "source": [
137
  "import subprocess\n",
138
  "import os\n",
 
177
  },
178
  {
179
  "cell_type": "code",
180
+ "execution_count": 4,
181
  "id": "b086e76c-4285-4036-8033-e4e45cb6966b",
182
  "metadata": {},
183
  "outputs": [],
 
185
  "gdf= df.execute()\n",
186
  "gdf = gdf.set_crs(\"EPSG:4326\")\n",
187
  "\n",
188
+ "# gdf.to_parquet(\"county_parties.parquet\")\n",
189
+ "# hf_upload(\"county_parties.parquet\", \"boettiger-lab/landvote\")\n",
190
  "\n",
191
+ "# gdf.to_file(\"county_parties.geojson\")\n",
192
+ "# hf_upload(\"county_parties.geojson\", \"boettiger-lab/landvote\")\n",
193
  "\n",
194
+ "# generate_pmtiles(\"county_parties.geojson\", \"county_parties.pmtiles\")\n",
195
+ "# hf_upload(\"county_parties.pmtiles\", \"boettiger-lab/landvote\")\n"
196
  ]
197
  },
198
  {
199
+ "cell_type": "markdown",
200
+ "id": "6193c4b9-0183-4aae-9a25-899a748fd65e",
 
201
  "metadata": {},
 
202
  "source": [
203
+ "# Checking map"
204
  ]
205
  },
206
  {
 
255
  "m\n"
256
  ]
257
  },
258
+ {
259
+ "cell_type": "markdown",
260
+ "id": "8c12fd16-a953-4273-9e0f-44b50eacf633",
261
+ "metadata": {},
262
+ "source": [
263
+ "# Getting Municipals "
264
+ ]
265
+ },
266
+ {
267
+ "cell_type": "code",
268
+ "execution_count": 15,
269
+ "id": "b3429fea-7c0d-4838-bcbb-6552079dc3b6",
270
+ "metadata": {},
271
+ "outputs": [
272
+ {
273
+ "data": {
274
+ "text/html": [
275
+ "<div>\n",
276
+ "<style scoped>\n",
277
+ " .dataframe tbody tr th:only-of-type {\n",
278
+ " vertical-align: middle;\n",
279
+ " }\n",
280
+ "\n",
281
+ " .dataframe tbody tr th {\n",
282
+ " vertical-align: top;\n",
283
+ " }\n",
284
+ "\n",
285
+ " .dataframe thead th {\n",
286
+ " text-align: right;\n",
287
+ " }\n",
288
+ "</style>\n",
289
+ "<table border=\"1\" class=\"dataframe\">\n",
290
+ " <thead>\n",
291
+ " <tr style=\"text-align: right;\">\n",
292
+ " <th></th>\n",
293
+ " <th>key</th>\n",
294
+ " <th>geometry</th>\n",
295
+ " <th>Status</th>\n",
296
+ " <th>yes</th>\n",
297
+ " <th>year</th>\n",
298
+ " <th>amount</th>\n",
299
+ " <th>log_amount</th>\n",
300
+ " <th>jurisdiction</th>\n",
301
+ " <th>current_party</th>\n",
302
+ " <th>previous_party</th>\n",
303
+ " </tr>\n",
304
+ " </thead>\n",
305
+ " <tbody>\n",
306
+ " <tr>\n",
307
+ " <th>0</th>\n",
308
+ " <td>San Luis Obispo-CA</td>\n",
309
+ " <td>POLYGON ((-120.58962 35.28275, -120.59096 35.2...</td>\n",
310
+ " <td>Pass</td>\n",
311
+ " <td>58.23%</td>\n",
312
+ " <td>2020</td>\n",
313
+ " <td>$21,600,000</td>\n",
314
+ " <td>16.8882</td>\n",
315
+ " <td>Municipal</td>\n",
316
+ " <td>DEMOCRAT</td>\n",
317
+ " <td>DEMOCRAT</td>\n",
318
+ " </tr>\n",
319
+ " <tr>\n",
320
+ " <th>1</th>\n",
321
+ " <td>Fruita-CO</td>\n",
322
+ " <td>POLYGON ((-108.65899 39.15887, -108.66033 39.1...</td>\n",
323
+ " <td>Pass</td>\n",
324
+ " <td>60.73%</td>\n",
325
+ " <td>2020</td>\n",
326
+ " <td>$1,300,000</td>\n",
327
+ " <td>14.0779</td>\n",
328
+ " <td>Municipal</td>\n",
329
+ " <td>REPUBLICAN</td>\n",
330
+ " <td>REPUBLICAN</td>\n",
331
+ " </tr>\n",
332
+ " <tr>\n",
333
+ " <th>2</th>\n",
334
+ " <td>Gig Harbor-WA</td>\n",
335
+ " <td>POLYGON ((-122.51787 47.32597, -122.51921 47.3...</td>\n",
336
+ " <td>Pass</td>\n",
337
+ " <td>62.05%</td>\n",
338
+ " <td>2004</td>\n",
339
+ " <td>$3,500,000</td>\n",
340
+ " <td>15.0683</td>\n",
341
+ " <td>Municipal</td>\n",
342
+ " <td>DEMOCRAT</td>\n",
343
+ " <td>DEMOCRAT</td>\n",
344
+ " </tr>\n",
345
+ " <tr>\n",
346
+ " <th>3</th>\n",
347
+ " <td>Jupiter-FL</td>\n",
348
+ " <td>POLYGON ((-80.02421 26.93422, -80.02555 26.920...</td>\n",
349
+ " <td>Pass</td>\n",
350
+ " <td>70.84%</td>\n",
351
+ " <td>2004</td>\n",
352
+ " <td>$17,000,000</td>\n",
353
+ " <td>16.6487</td>\n",
354
+ " <td>Municipal</td>\n",
355
+ " <td>DEMOCRAT</td>\n",
356
+ " <td>DEMOCRAT</td>\n",
357
+ " </tr>\n",
358
+ " <tr>\n",
359
+ " <th>4</th>\n",
360
+ " <td>Bozeman-MT</td>\n",
361
+ " <td>POLYGON ((-110.97405 45.67943, -110.97539 45.6...</td>\n",
362
+ " <td>Pass</td>\n",
363
+ " <td>73.39%</td>\n",
364
+ " <td>2012</td>\n",
365
+ " <td>$7,500,000</td>\n",
366
+ " <td>15.8304</td>\n",
367
+ " <td>Municipal</td>\n",
368
+ " <td>REPUBLICAN</td>\n",
369
+ " <td>DEMOCRAT</td>\n",
370
+ " </tr>\n",
371
+ " <tr>\n",
372
+ " <th>...</th>\n",
373
+ " <td>...</td>\n",
374
+ " <td>...</td>\n",
375
+ " <td>...</td>\n",
376
+ " <td>...</td>\n",
377
+ " <td>...</td>\n",
378
+ " <td>...</td>\n",
379
+ " <td>...</td>\n",
380
+ " <td>...</td>\n",
381
+ " <td>...</td>\n",
382
+ " <td>...</td>\n",
383
+ " </tr>\n",
384
+ " <tr>\n",
385
+ " <th>268</th>\n",
386
+ " <td>Chandler-AZ</td>\n",
387
+ " <td>POLYGON ((-111.77118 33.3062, -111.77253 33.29...</td>\n",
388
+ " <td>Pass</td>\n",
389
+ " <td>75.16%</td>\n",
390
+ " <td>2004</td>\n",
391
+ " <td>$17,350,000</td>\n",
392
+ " <td>16.6691</td>\n",
393
+ " <td>Municipal</td>\n",
394
+ " <td>REPUBLICAN</td>\n",
395
+ " <td>REPUBLICAN</td>\n",
396
+ " </tr>\n",
397
+ " <tr>\n",
398
+ " <th>269</th>\n",
399
+ " <td>Medfield-MA</td>\n",
400
+ " <td>POLYGON ((-71.23546 42.18656, -71.23681 42.172...</td>\n",
401
+ " <td>Pass</td>\n",
402
+ " <td>84.17%</td>\n",
403
+ " <td>2008</td>\n",
404
+ " <td>$1,550,000</td>\n",
405
+ " <td>14.2538</td>\n",
406
+ " <td>Municipal</td>\n",
407
+ " <td>DEMOCRAT</td>\n",
408
+ " <td>DEMOCRAT</td>\n",
409
+ " </tr>\n",
410
+ " <tr>\n",
411
+ " <th>270</th>\n",
412
+ " <td>Somerville-MA</td>\n",
413
+ " <td>POLYGON ((-71.0295 42.3876, -71.03084 42.37394...</td>\n",
414
+ " <td>Pass</td>\n",
415
+ " <td>76.07%</td>\n",
416
+ " <td>2012</td>\n",
417
+ " <td>$9,659,333</td>\n",
418
+ " <td>16.0834</td>\n",
419
+ " <td>Municipal</td>\n",
420
+ " <td>DEMOCRAT</td>\n",
421
+ " <td>DEMOCRAT</td>\n",
422
+ " </tr>\n",
423
+ " <tr>\n",
424
+ " <th>271</th>\n",
425
+ " <td>Dryden-NY</td>\n",
426
+ " <td>POLYGON ((-76.22716 42.49091, -76.2285 42.4772...</td>\n",
427
+ " <td>Fail</td>\n",
428
+ " <td>44.07%</td>\n",
429
+ " <td>2016</td>\n",
430
+ " <td>$71,800</td>\n",
431
+ " <td>11.1816</td>\n",
432
+ " <td>Municipal</td>\n",
433
+ " <td>DEMOCRAT</td>\n",
434
+ " <td>DEMOCRAT</td>\n",
435
+ " </tr>\n",
436
+ " <tr>\n",
437
+ " <th>272</th>\n",
438
+ " <td>Grafton-WI</td>\n",
439
+ " <td>POLYGON ((-87.88178 43.31952, -87.88313 43.305...</td>\n",
440
+ " <td>Fail</td>\n",
441
+ " <td>28.78%</td>\n",
442
+ " <td>2004</td>\n",
443
+ " <td>$1,120,000</td>\n",
444
+ " <td>13.9288</td>\n",
445
+ " <td>Municipal</td>\n",
446
+ " <td>REPUBLICAN</td>\n",
447
+ " <td>REPUBLICAN</td>\n",
448
+ " </tr>\n",
449
+ " </tbody>\n",
450
+ "</table>\n",
451
+ "<p>273 rows × 10 columns</p>\n",
452
+ "</div>"
453
+ ],
454
+ "text/plain": [
455
+ " key geometry \\\n",
456
+ "0 San Luis Obispo-CA POLYGON ((-120.58962 35.28275, -120.59096 35.2... \n",
457
+ "1 Fruita-CO POLYGON ((-108.65899 39.15887, -108.66033 39.1... \n",
458
+ "2 Gig Harbor-WA POLYGON ((-122.51787 47.32597, -122.51921 47.3... \n",
459
+ "3 Jupiter-FL POLYGON ((-80.02421 26.93422, -80.02555 26.920... \n",
460
+ "4 Bozeman-MT POLYGON ((-110.97405 45.67943, -110.97539 45.6... \n",
461
+ ".. ... ... \n",
462
+ "268 Chandler-AZ POLYGON ((-111.77118 33.3062, -111.77253 33.29... \n",
463
+ "269 Medfield-MA POLYGON ((-71.23546 42.18656, -71.23681 42.172... \n",
464
+ "270 Somerville-MA POLYGON ((-71.0295 42.3876, -71.03084 42.37394... \n",
465
+ "271 Dryden-NY POLYGON ((-76.22716 42.49091, -76.2285 42.4772... \n",
466
+ "272 Grafton-WI POLYGON ((-87.88178 43.31952, -87.88313 43.305... \n",
467
+ "\n",
468
+ " Status yes year amount log_amount jurisdiction current_party \\\n",
469
+ "0 Pass 58.23% 2020 $21,600,000 16.8882 Municipal DEMOCRAT \n",
470
+ "1 Pass 60.73% 2020 $1,300,000 14.0779 Municipal REPUBLICAN \n",
471
+ "2 Pass 62.05% 2004 $3,500,000 15.0683 Municipal DEMOCRAT \n",
472
+ "3 Pass 70.84% 2004 $17,000,000 16.6487 Municipal DEMOCRAT \n",
473
+ "4 Pass 73.39% 2012 $7,500,000 15.8304 Municipal REPUBLICAN \n",
474
+ ".. ... ... ... ... ... ... ... \n",
475
+ "268 Pass 75.16% 2004 $17,350,000 16.6691 Municipal REPUBLICAN \n",
476
+ "269 Pass 84.17% 2008 $1,550,000 14.2538 Municipal DEMOCRAT \n",
477
+ "270 Pass 76.07% 2012 $9,659,333 16.0834 Municipal DEMOCRAT \n",
478
+ "271 Fail 44.07% 2016 $71,800 11.1816 Municipal DEMOCRAT \n",
479
+ "272 Fail 28.78% 2004 $1,120,000 13.9288 Municipal REPUBLICAN \n",
480
+ "\n",
481
+ " previous_party \n",
482
+ "0 DEMOCRAT \n",
483
+ "1 REPUBLICAN \n",
484
+ "2 DEMOCRAT \n",
485
+ "3 DEMOCRAT \n",
486
+ "4 DEMOCRAT \n",
487
+ ".. ... \n",
488
+ "268 REPUBLICAN \n",
489
+ "269 DEMOCRAT \n",
490
+ "270 DEMOCRAT \n",
491
+ "271 DEMOCRAT \n",
492
+ "272 REPUBLICAN \n",
493
+ "\n",
494
+ "[273 rows x 10 columns]"
495
+ ]
496
+ },
497
+ "execution_count": 15,
498
+ "metadata": {},
499
+ "output_type": "execute_result"
500
+ }
501
+ ],
502
+ "source": [
503
+ "\n",
504
+ "localities_boundaries = \"us_localities.parquet\"\n",
505
+ "locality = conn.read_parquet(localities_boundaries)\n",
506
+ "landvote = conn.read_csv(\"landvote.csv\")\n",
507
+ "\n",
508
+ "#needed to redo this, since I didn't save county in \"votes.parquet\". \n",
509
+ "vote_local = (landvote\n",
510
+ " .filter(_[\"Jurisdiction Type\"] == \"Municipal\")\n",
511
+ " .rename(city = \"Jurisdiction Name\", state_id = \"State\")\n",
512
+ " .mutate(key = _.city + ibis.literal('-') + _.state_id)\n",
513
+ " .rename(amount = 'Conservation Funds at Stake', yes = '% Yes')\n",
514
+ " .mutate(amount_n=_.amount.replace('$', '').replace(',', '').cast('float'))\n",
515
+ " .mutate(log_amount=_.amount_n.log())\n",
516
+ " .mutate(year=_['Date'].year().cast('int32'))\n",
517
+ " .mutate(\n",
518
+ " yes=ibis.case()\n",
519
+ " .when(_.yes.isin(['Pass', 'None','Fail']), None) # Handle non-numeric cases\n",
520
+ " .when(_.yes.notnull(), (_.yes.replace('%', '').cast('float').round(2).cast(dt.float64)).cast(dt.string) + '%') # Convert valid percentages and add %\n",
521
+ " .else_(None) # Default to None for other cases\n",
522
+ " .end()\n",
523
+ " )\n",
524
+ " .mutate(log_amount = _.log_amount.round(4))\n",
525
+ " .select('key', 'Status', 'yes', 'year', 'amount', 'log_amount', )\n",
526
+ " )\n",
527
+ "\n",
528
+ "# getting the county parties for each municipal \n",
529
+ "df_municipals = (locality \n",
530
+ " .mutate(key_municipal = _.name + ibis.literal('-') + _.state_id) \n",
531
+ " .mutate(key = (_.county + ibis.literal('-') + _.state_id).upper()) \n",
532
+ " .select('key', 'geometry','key_municipal','name')\n",
533
+ " .right_join(vote_local, [_.key_municipal == vote_local[\"key\"]])\n",
534
+ " .mutate(jurisdiction = ibis.literal(\"Municipal\"))\n",
535
+ " .cast({\"geometry\": \"geometry\"})\n",
536
+ " .mutate(geometry = _.geometry.buffer(.07))\n",
537
+ " .join(county_parties, [\"key\",\"year\"],how='inner')\n",
538
+ " .rename(county = \"key\")\n",
539
+ " .rename(key = \"key_municipal\")\n",
540
+ " .select('key','geometry','Status','yes','year','amount','log_amount','jurisdiction','current_party','previous_party')\n",
541
+ " )\n",
542
+ "\n",
543
+ "\n",
544
+ "gdf_municipals = df_municipals.execute()\n",
545
+ "gdf_municipals = gdf_municipals.set_crs(\"EPSG:4326\")\n",
546
+ "gdf_municipals\n",
547
+ "\n",
548
+ "\n",
549
+ "# gdf_municipals.to_parquet(\"municipal_parties.parquet\")\n",
550
+ "# hf_upload(\"municipal_parties.parquet\", \"boettiger-lab/landvote\")\n",
551
+ "\n",
552
+ "# gdf_municipals.to_file(\"municipal_parties.geojson\")\n",
553
+ "# hf_upload(\"municipal_parties.geojson\", \"boettiger-lab/landvote\")\n",
554
+ "\n",
555
+ "# generate_pmtiles(\"municipal_parties.geojson\", \"municipal_parties.pmtiles\")\n",
556
+ "# hf_upload(\"municipal_parties.pmtiles\", \"boettiger-lab/landvote\")\n"
557
+ ]
558
+ },
559
  {
560
  "cell_type": "code",
561
  "execution_count": null,
562
+ "id": "322b9a85-bdf9-45f9-9b19-695cc1b996e8",
563
  "metadata": {},
564
  "outputs": [],
565
  "source": []