Skip to content

Instantly share code, notes, and snippets.

@ajparsons
ajparsons / constituency_converstion.py
Created September 12, 2023 08:19
Script to convert data between different geography types
"""
This file is a standlone library to convert polling data from one geography to another.
It has minimal dependencies beyond pandas.
Ideally it uses parquet and pyarrow - but if this is an obstacle,
adjust the parquet references to csv.
Note, when converting to LAD23, this is the lower level geography.
Additional conversion for higher level is in convert_specific_polling.py
in the climate_mrp_polling package.
@ajparsons
ajparsons / compress_docker_vdisk.txt
Created December 3, 2021 11:25
Windows home doesn't give you the easy commands to steal space back from an expanding wsl volume, here's how you do that.
wsl --shutdown
diskpart
select vdisk file="C:\Users\USER\AppData\Local\Docker\wsl\data\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
# Wikidata/R script to find the midpoint of all current star trek tv/films
library(WikidataQueryServiceR)
query <- '
SELECT DISTINCT ?item ?itemLabel ?duration ?startrekLabel
WHERE
{
#star trek films
{?item wdt:P31 wd:Q61283808.}
# Roundtrip json bods to xlsx
import os
import openpyxl
import json
from tempfile import TemporaryDirectory
from flattentool import flatten, unflatten
@ajparsons
ajparsons / assemblies_websites.json
Created July 17, 2019 13:45
assemblies_websites.json
[{"children": [], "child_of": null, "link": "https://docs.google.com/document/d/1as8y1rV3EEnyHDTlKsWZ988NnUs5QvUgT-RruUrCwV0/edit#heading=h.8n1yv86y9wvz", "name": "Introduction", "id": 1}, {"children": [{"children": [], "child_of": 2, "link": "https://docs.google.com/document/d/1as8y1rV3EEnyHDTlKsWZ988NnUs5QvUgT-RruUrCwV0/edit#heading=h.2zqzc2994t4y", "name": "Design", "id": 3}, {"children": [], "child_of": 2, "link": "https://docs.google.com/document/d/1as8y1rV3EEnyHDTlKsWZ988NnUs5QvUgT-RruUrCwV0/edit#heading=h.3w2umh6zwbbd", "name": "Discoverability", "id": 4}, {"children": [], "child_of": 2, "link": "https://docs.google.com/document/d/1as8y1rV3EEnyHDTlKsWZ988NnUs5QvUgT-RruUrCwV0/edit#heading=h.xxzaducm929a", "name": "Accessibility", "id": 5}, {"children": [], "child_of": 2, "link": "https://docs.google.com/document/d/1as8y1rV3EEnyHDTlKsWZ988NnUs5QvUgT-RruUrCwV0/edit#heading=h.s7hmntikgtgr", "name": "Plain language", "id": 6}, {"children": [], "child_of": 2, "link": "https://docs.google.com/document/d/1as8y
@ajparsons
ajparsons / assemblies_toc.json
Created June 28, 2019 08:39
table of contents for assembleis doc
[{"children": [], "child_of": null, "link": "https://docs.google.com/document/d/17sMqrBrQO89pkSly8vg2CNOvm26bsqgPrZ-S-q4EsvQ/edit#heading=h.apm3u78ms6oq", "name": "Introduction", "id": 1}, {"children": [], "child_of": null, "link": "https://docs.google.com/document/d/17sMqrBrQO89pkSly8vg2CNOvm26bsqgPrZ-S-q4EsvQ/edit#heading=h.hl4hiday6wcc", "name": "Potential uses of digital tools", "id": 2}, {"children": [{"children": [], "child_of": 3, "link": "https://docs.google.com/document/d/17sMqrBrQO89pkSly8vg2CNOvm26bsqgPrZ-S-q4EsvQ/edit#heading=h.wnh22yd3dipg", "name": "Question forming", "id": 4}, {"children": [], "child_of": 3, "link": "https://docs.google.com/document/d/17sMqrBrQO89pkSly8vg2CNOvm26bsqgPrZ-S-q4EsvQ/edit#heading=h.lfshf3fygn0a", "name": "Public submissions", "id": 5}, {"children": [], "child_of": 3, "link": "https://docs.google.com/document/d/17sMqrBrQO89pkSly8vg2CNOvm26bsqgPrZ-S-q4EsvQ/edit#heading=h.v3wu5gbewhp4", "name": "Finding experts and stakeholders", "id": 6}], "child_of": null, "link": "h