You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(docs): Add markdown-exec for executable code blocks
Replace manually-written output blocks with code that runs at build time
via markdown-exec, so docs always reflect the current API behavior.
Converted pages: quickstart, acs-data, decennial-data, geography,
margins-of-error, migration-flows, multi-year, spatial.
Pages left unconverted due to pre-existing API bugs (get_pums 400s,
load_variables wrong URL pattern, get_estimates 404s): variables,
pums-microdata, population-estimates, survey-design.
Also adds --extra spatial to .readthedocs.yaml so geometry=True
blocks can execute during the docs build.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 06037101300 Census Tract 1013, Los ... B17001_002 1045.0 344.0 POLYGON ((-118.27310 34.04055, -118.26950 34....
86
-
3 06037101400 Census Tract 1014, Los ... B17001_002 627.0 258.0 POLYGON ((-118.28016 34.04400, -118.27670 34....
87
-
4 06037102100 Census Tract 1021, Los ... B17001_002 490.0 199.0 POLYGON ((-118.24380 34.06120, -118.24117 34....
88
-
```
89
-
90
83
1.**geography** -- `"tract"` gives you Census tracts, small statistical areas with 1,200--8,000 people.
91
84
2.**variables** -- `B17001_002` is the count of people whose income is below the poverty level (from table B17001).
92
85
3.**state** -- Required for tract-level queries so the API knows which state to pull tracts from.
93
86
4.**county** -- `"037"` is the FIPS code for Los Angeles County. Use `pypums.datasets.fips.lookup_fips(state="California", county="Los Angeles County")` to look up codes.
94
87
5.**geometry** -- When `True`, PyPUMS downloads cartographic boundary shapefiles (via pygris, cached locally) and merges them with the data. The result is a `GeoDataFrame` with a `geometry` column.
95
88
89
+
```python exec="on" session="qs-spatial"
90
+
# markdown-exec: hide
91
+
import pypums
92
+
la_poverty = pypums.get_acs(
93
+
geography="tract",
94
+
variables="B17001_002",
95
+
state="CA",
96
+
county="037",
97
+
year=2023,
98
+
survey="acs5",
99
+
geometry=True,
100
+
)
101
+
print(la_poverty.head())
102
+
print(type(la_poverty))
103
+
```
104
+
96
105
Now plot it with [Altair](https://altair-viz.github.io/):
97
106
98
107
```python
@@ -247,15 +256,17 @@ print(ca_pums.head())
247
256
4.**survey** -- `"acs1"` (1-year) or `"acs5"` (5-year, default).
248
257
5.**recode** -- When `True`, PyPUMS adds `*_label` columns that translate numeric codes into human-readable values. For example, `SEX=1` gets `SEX_label="Male"`.
249
258
250
-
**Expected output:**
251
-
252
-
```
253
-
SERIALNO SPORDER PWGTP ST PUMA AGEP SEX WAGP SEX_label
0 commit comments