countries_topology.json is derived from the Natural Earth 1:110m Cultural Vectors.
Each feature has an id
property, which is the ISO A2 country code for the country;
and a properties.title
property, which is the English-language name of the country.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ehrql import case, codelist_from_csv, create_dataset, days, when | |
from ehrql.tables.beta.core import medications, patients | |
from ehrql.tables.beta.tpp import ( | |
addresses, | |
clinical_events, | |
hospital_admissions, | |
practice_registrations, | |
) | |
index_date = "2023-10-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import pathlib | |
def match_paths_1(pattern): | |
# not a generator function | |
return (pathlib.Path(path) for path in glob.iglob(pattern)) | |
def match_paths_2(pattern): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A common pattern when using OpenSAFELY for time series analysis is to extract one | |
# cohort for slow-to-extract variables that we don't expect to change over time, and | |
# multiple cohorts (e.g. by week or by month) for fast-to-extract variables that we | |
# expect to change over time. Each "fast" cohort is then joined to the "slow" cohort for | |
# analysis. | |
# | |
# In this gist, we compare the memory profiles of two join strategies found in the | |
# OpenSAFELY documentation: a map strategy and a merge strategy. We find that on a | |
# dataset with an order of magnitude difference between the population size and the | |
# sample size, the map strategy uses roughly 2.9 times more memory than the merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig(level=logging.INFO) | |
class LoggingProperty: | |
def __init__(self): | |
logging.info(f"Initializing '{self.__class__.__name__}'") | |
def __set_name__(self, owner, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dataclasses | |
import random | |
import typing | |
@dataclasses.dataclass | |
class PointDC: | |
x: float | |
y: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit | |
height: 960 | |
scrolling: no | |
border: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 0, | |
"parent": null, | |
"name": "Name" | |
}, | |
{ | |
"id": 1, | |
"parent": 0, | |
"name": "Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dimension | metric | |
---|---|---|
A | 1 | |
A | 1 | |
B | 2 | |
B | 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A | 1 | |
---|---|---|
A | 1 | |
B | 2 | |
B | 2 |
NewerOlder