Publish reviewed dataset guide, preserving later R examples
Browse files
README.md
CHANGED
|
@@ -11,32 +11,99 @@ tags:
|
|
| 11 |
- law
|
| 12 |
- duckdb
|
| 13 |
- datapond
|
| 14 |
-
pretty_name: The Supreme Court Database (SCDB), 1791-
|
| 15 |
size_categories:
|
| 16 |
- 100K<n<1M
|
| 17 |
---
|
| 18 |
|
| 19 |
# Supreme Court Database (SCDB)
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
| Table | Description | Row Count | Column Count |
|
| 28 |
|---|---|---|---|
|
| 29 |
-
| `
|
| 30 |
-
| `
|
| 31 |
-
| `
|
| 32 |
-
| `
|
| 33 |
-
| `
|
| 34 |
-
| `
|
| 35 |
-
| `
|
| 36 |
-
| `
|
| 37 |
| `codes` | SCDB online code book: the label for every coded value (variable, code, label; justices carry their service dates in extra) | 2,949 | 4 |
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
```sql
|
| 42 |
INSTALL httpfs; LOAD httpfs;
|
|
@@ -46,6 +113,18 @@ SELECT term, decision_direction, COUNT(*) AS n
|
|
| 46 |
FROM scdb.v_cases WHERE term >= 2015 GROUP BY 1, 2 ORDER BY 1, 2;
|
| 47 |
```
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
### R with DBI and duckdb
|
| 50 |
|
| 51 |
Install the dependencies once with `install.packages(c("DBI", "duckdb"))`.
|
|
|
|
| 11 |
- law
|
| 12 |
- duckdb
|
| 13 |
- datapond
|
| 14 |
+
pretty_name: The Supreme Court Database (SCDB), 1791-2025 terms, case- and justice-level with the code book
|
| 15 |
size_categories:
|
| 16 |
- 100K<n<1M
|
| 17 |
---
|
| 18 |
|
| 19 |
# Supreme Court Database (SCDB)
|
| 20 |
|
| 21 |
+
Coded U.S. Supreme Court decisions and individual justices’ votes from the Supreme Court Database, combining the 1791–1945 legacy files with modern release 2026_01. Start with `v_cases` for labelled case-level analysis or `justice_votes` for voting records. Alternative docket, legal-provision and vote-split tables repeat aspects of the same decisions; do not add them together as additional cases.
|
| 22 |
+
|
| 23 |
+
## Start querying
|
| 24 |
+
|
| 25 |
+
Show five Supreme Court case records from the 2020 term onward, with the case ID, term and recorded decision direction. The rows come from the case-level view, rather than the separate justice-vote tables.
|
| 26 |
+
|
| 27 |
+
`term` identifies the Supreme Court term. `decision_direction` is SCDB’s classification of the decision, shown as a label by `v_cases`.
|
| 28 |
+
|
| 29 |
+
Choose R or Python. Install datapond once: use `install.packages("datapond")` in R, or run `python -m pip install datapond` in a terminal.
|
| 30 |
+
|
| 31 |
+
### R
|
| 32 |
+
|
| 33 |
+
```r
|
| 34 |
+
library(datapond)
|
| 35 |
+
con <- dp_connect("scdb")
|
| 36 |
+
tryCatch({
|
| 37 |
+
DBI::dbExecute(con, "SET threads=1")
|
| 38 |
+
DBI::dbExecute(con, "SET memory_limit='128MiB'")
|
| 39 |
+
DBI::dbExecute(con, "SET max_temp_directory_size='0B'")
|
| 40 |
+
print(DBI::dbGetQuery(con, "SELECT caseId,term,decision_direction FROM v_cases WHERE term>=2020 ORDER BY caseId LIMIT 5"))
|
| 41 |
+
}, finally = dp_disconnect(con))
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### Python
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
import datapond
|
| 48 |
+
con = datapond.connect('scdb')
|
| 49 |
+
try:
|
| 50 |
+
con.execute("SET threads=1")
|
| 51 |
+
con.execute("SET memory_limit='128MiB'")
|
| 52 |
+
con.execute("SET max_temp_directory_size='0B'")
|
| 53 |
+
print(con.execute("""SELECT caseId,term,decision_direction FROM v_cases WHERE term>=2020 ORDER BY caseId LIMIT 5""").fetchall())
|
| 54 |
+
finally:
|
| 55 |
+
con.close()
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
Queries run on your computer and read the byte ranges they need. A small result can still require a large scan. These examples limit DuckDB to one thread and a 128 MiB buffer pool with disk spill disabled; that is not a limit on the entire R or Python process. Larger analyses may need more memory or a local download with enough disk space.
|
| 59 |
+
|
| 60 |
+
<a id="additional-dataset-notes"></a>
|
| 61 |
+
|
| 62 |
+
## Tables, fields and joins
|
| 63 |
+
|
| 64 |
+
See the [data dictionary](https://github.com/ian-nason/scdb-database/blob/main/DICTIONARY.md) for column definitions.
|
| 65 |
+
|
| 66 |
+
**677,452 rows across 9 tables.** Start with `v_cases`, the decoded case-level view, or `justice_votes` for one row per justice and case.
|
| 67 |
|
| 68 |
| Table | Description | Row Count | Column Count |
|
| 69 |
|---|---|---|---|
|
| 70 |
+
| `cases` | One row per Supreme Court case by citation, 1791-2025 terms (modern 1946+ release 2026_01 plus the Legacy database): dates, citations, parties, origin, issue, decision direction, disposition, vote counts, opinion writer | 29,270 | 54 |
|
| 71 |
+
| `justice_votes` | One row per justice per case, 1791-2025 terms: the case variables plus the justice's vote, opinion, direction, majority and agreement | 256,469 | 62 |
|
| 72 |
+
| `cases_docket` | Modern cases split one row per docket number consolidated in the decision (1946-2025 terms) | 10,932 | 54 |
|
| 73 |
+
| `cases_legal_provision` | Modern cases split one row per legal provision considered (1946-2025 terms) | 14,016 | 54 |
|
| 74 |
+
| `cases_vote` | Modern cases split one row per issue/vote split (1946-2025 terms) | 14,090 | 54 |
|
| 75 |
+
| `justice_votes_docket` | Justice-level rows of cases_docket (1946-2025 terms) | 97,918 | 62 |
|
| 76 |
+
| `justice_votes_legal_provision` | Justice-level rows of cases_legal_provision (1946-2025 terms) | 125,571 | 62 |
|
| 77 |
+
| `justice_votes_vote` | Justice-level rows of cases_vote (1946-2025 terms) | 126,237 | 62 |
|
| 78 |
| `codes` | SCDB online code book: the label for every coded value (variable, code, label; justices carry their service dates in extra) | 2,949 | 4 |
|
| 79 |
|
| 80 |
+
`database` says `modern` or `legacy` on every row. Keys: `caseId` (`term-number`),
|
| 81 |
+
`docketId`, `caseIssuesId`, `voteId`, `justice`. `v_cases` is `cases` with issue area,
|
| 82 |
+
issue, decision direction, decision type, winning party and opinion writer decoded.
|
| 83 |
+
Columns and null rates: `DICTIONARY.md`; variable definitions: the
|
| 84 |
+
[online code book](http://scdb.wustl.edu/documentation.php).
|
| 85 |
+
|
| 86 |
+
## Researcher caveats
|
| 87 |
+
|
| 88 |
+
- **Units of analysis.** The SCDB publishes the same cases four ways (by citation, docket,
|
| 89 |
+
legal provision, vote split). `cases` and `justice_votes` are the citation-level files most
|
| 90 |
+
analyses use; the split tables repeat case variables across their rows, so do not add them.
|
| 91 |
+
- **Codes are integers; labels live in `codes`.** Justice ids, issue codes (278), parties
|
| 92 |
+
(311), lower-court dispositions and so on are all there. `-99` in `justice_votes.justice`
|
| 93 |
+
is the SCDB's own "unknown" in a few legacy rows.
|
| 94 |
+
- **Legacy vs modern.** The Legacy database has the two citation-level units only, and its
|
| 95 |
+
justice-centered file carries 25 cases (1896-1931) that its case-centered file lacks; they
|
| 96 |
+
are kept as published. Some variables are coded less completely before 1946.
|
| 97 |
+
|
| 98 |
+
Dates are stored as `DATE`; the source uses `m/d/yyyy`.
|
| 99 |
+
|
| 100 |
+
<a id="advanced-access-query-it-remotely"></a>
|
| 101 |
+
|
| 102 |
+
## Other ways to connect: direct DuckDB SQL
|
| 103 |
+
|
| 104 |
+
This direct example does not set resource limits; the first R/Python examples above do.
|
| 105 |
+
|
| 106 |
+
This alternative uses a DuckDB SQL client and the `scdb` catalog alias to count cases by term and recorded decision direction. It is not another required setup step; the datapond route is above.
|
| 107 |
|
| 108 |
```sql
|
| 109 |
INSTALL httpfs; LOAD httpfs;
|
|
|
|
| 113 |
FROM scdb.v_cases WHERE term >= 2015 GROUP BY 1, 2 ORDER BY 1, 2;
|
| 114 |
```
|
| 115 |
|
| 116 |
+
<a id="coverage-fields-and-sources"></a>
|
| 117 |
+
|
| 118 |
+
## Sources and maintenance
|
| 119 |
+
|
| 120 |
+
### Sources, license and build
|
| 121 |
+
|
| 122 |
+
Source: [The Supreme Court Database (Washington University in St. Louis)](http://scdb.wustl.edu/data.php). License: CC BY-NC 3.0.
|
| 123 |
+
|
| 124 |
+
Build pipeline and caveats: https://github.com/ian-nason/scdb-database
|
| 125 |
+
Source: http://scdb.wustl.edu (Spaeth, Epstein et al.; CC BY-NC 3.0 - cite the SCDB).
|
| 126 |
+
|
| 127 |
+
|
| 128 |
### R with DBI and duckdb
|
| 129 |
|
| 130 |
Install the dependencies once with `install.packages(c("DBI", "duckdb"))`.
|