Clarify dataset units, query setup and snapshot caveats
Browse files
README.md
CHANGED
|
@@ -27,6 +27,8 @@ Built with [qcew-database](https://github.com/ian-nason/qcew-database). Publishe
|
|
| 27 |
|
| 28 |
## Quick Start
|
| 29 |
|
|
|
|
|
|
|
| 30 |
### DuckDB CLI
|
| 31 |
|
| 32 |
```sql
|
|
@@ -44,7 +46,9 @@ WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10'
|
|
| 44 |
AND agglvl_code = '10' AND size_code = '0' AND year = '2025' AND qtr = 'A';
|
| 45 |
```
|
| 46 |
|
| 47 |
-
The database is
|
|
|
|
|
|
|
| 48 |
|
| 49 |
```
|
| 50 |
https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb
|
|
@@ -52,6 +56,8 @@ https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233f
|
|
| 52 |
|
| 53 |
### Python (duckdb)
|
| 54 |
|
|
|
|
|
|
|
| 55 |
```python
|
| 56 |
import duckdb
|
| 57 |
con = duckdb.connect(config={"memory_limit": "128MiB", "threads": "1", "max_temp_directory_size": "0B"})
|
|
@@ -68,7 +74,9 @@ con.sql("""
|
|
| 68 |
con.close()
|
| 69 |
```
|
| 70 |
|
| 71 |
-
### R
|
|
|
|
|
|
|
| 72 |
|
| 73 |
```r
|
| 74 |
library(DBI)
|
|
@@ -87,13 +95,16 @@ In the tested R DuckDB 1.5.5 configuration, BIGINT and DECIMAL results are expos
|
|
| 87 |
|
| 88 |
### datapond package
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
```python
|
| 93 |
import datapond
|
| 94 |
print(datapond.list())
|
| 95 |
datapond.describe('qcew', table='annual_raw')
|
| 96 |
con = datapond.connect('qcew')
|
|
|
|
| 97 |
con.sql("SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'").show()
|
| 98 |
con.close()
|
| 99 |
```
|
|
@@ -102,6 +113,7 @@ con.close()
|
|
| 102 |
library(datapond)
|
| 103 |
dp_list()
|
| 104 |
con <- dp_connect('qcew')
|
|
|
|
| 105 |
dp_describe(con, table = 'annual_raw')
|
| 106 |
DBI::dbGetQuery(con, "SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'")
|
| 107 |
dp_disconnect(con)
|
|
@@ -125,13 +137,15 @@ DBI::dbGetQuery(con, "SELECT annual_avg_emplvl, total_annual_wages FROM annual W
|
|
| 125 |
dp_disconnect(con)
|
| 126 |
```
|
| 127 |
|
| 128 |
-
Verify the recorded artifact SHA-256 after downloading. In
|
| 129 |
|
| 130 |
Default-catalog discovery and representative remote queries were verified after the registry merge. Earlier full-download checks used an isolated candidate registry. See [consumer verification](https://github.com/ian-nason/qcew-database/blob/main/docs/CONSUMERS.md) for exact client versions, paths, resource limits and download behavior. The direct URL examples above work independently of the catalog. The SQL examples below use the `qcew` catalog alias from the direct-URL quick start.
|
| 131 |
|
| 132 |
|
| 133 |
## Tables
|
| 134 |
|
|
|
|
|
|
|
| 135 |
| Table | Description | Rows | Columns |
|
| 136 |
|---|---|---:|---:|
|
| 137 |
| `annual_raw` | 2025 annual QCEW rows preserving all 38 source fields, numeric placeholders and disclosure flags. Mixed nested geographies, industries and ownership totals; do not sum unfiltered | 3,089,813 | 38 |
|
|
@@ -198,7 +212,7 @@ The full set is in [examples.sql](https://github.com/ian-nason/qcew-database/blo
|
|
| 198 |
|
| 199 |
1. **Suppression flags are independent and partial.** Three flags (`disclosure_code`, `lq_disclosure_code`, `oty_disclosure_code`) each govern their own measures. There are 1,860,359 suppressed level rows, 1,872,172 suppressed quotient rows and 1,937,791 suppressed change rows. Suppressed rows still carry valid establishment counts. Never read a suppressed zero as zero employment or pay.
|
| 200 |
2. **Suppressed cells are inside published totals.** Summing disclosed detail gives an incomplete total; the view does not estimate or back out suppressed values. Report how many eligible cells have published values ([BLS disclosure note](https://www.bls.gov/cew/publications/employment-and-wages-annual-averages/2025/home.htm#disclosure-restrictions)).
|
| 201 |
-
3. **Rows
|
| 202 |
4. **Geography moves.** Connecticut uses planning-region codes from 2024 data; codes ending `999` are unallocated. Check `areas` before fixing a study universe.
|
| 203 |
5. **Industry is 2022 NAICS.** `62` is health care and social assistance; `621` ambulatory care; `622` hospitals. Do not splice historical series without checking classification changes.
|
| 204 |
6. **Employment counts covered jobs, not people.** A worker with two covered employers counts twice; the self-employed and other uncovered groups are absent. Annual employment averages 12 monthly levels; establishments average four quarters; rounding can break exact additivity.
|
|
|
|
| 27 |
|
| 28 |
## Quick Start
|
| 29 |
|
| 30 |
+
Choose one route: the [datapond package](#datapond-package) finds the database by catalog ID; the direct [Python](#python-duckdb), [R](#r-with-dbi-and-duckdb) and SQL examples use a fixed artifact URL. These are alternatives, not steps that must all be run. The SQL block requires a DuckDB SQL client.
|
| 31 |
+
|
| 32 |
### DuckDB CLI
|
| 33 |
|
| 34 |
```sql
|
|
|
|
| 46 |
AND agglvl_code = '10' AND size_code = '0' AND year = '2025' AND qtr = 'A';
|
| 47 |
```
|
| 48 |
|
| 49 |
+
The database file is 186.5 MiB. Filtered queries fetch only the byte ranges they touch; an unfiltered scan of `annual_raw` reads most of the file, so download it locally if you plan to scan repeatedly. File size is disk storage, not a RAM estimate. Remote queries still run on your machine and can transfer much of the file. A filter or `LIMIT` after a join or aggregate does not guarantee a small scan. The 128 MiB setting limits DuckDB's buffer pool, not the whole Python/R process; with spill disabled, a larger query can fail at that limit. Download only if you have room for the file, temporary download bytes and any existing copy.
|
| 50 |
+
|
| 51 |
+
The examples use this immutable artifact URL:
|
| 52 |
|
| 53 |
```
|
| 54 |
https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb
|
|
|
|
| 56 |
|
| 57 |
### Python (duckdb)
|
| 58 |
|
| 59 |
+
Install the Python dependency once in the environment that runs your query: `python -m pip install duckdb`.
|
| 60 |
+
|
| 61 |
```python
|
| 62 |
import duckdb
|
| 63 |
con = duckdb.connect(config={"memory_limit": "128MiB", "threads": "1", "max_temp_directory_size": "0B"})
|
|
|
|
| 74 |
con.close()
|
| 75 |
```
|
| 76 |
|
| 77 |
+
### R with DBI and duckdb
|
| 78 |
+
|
| 79 |
+
Install the R dependencies once: `install.packages(c("DBI", "duckdb"))`.
|
| 80 |
|
| 81 |
```r
|
| 82 |
library(DBI)
|
|
|
|
| 95 |
|
| 96 |
### datapond package
|
| 97 |
|
| 98 |
+
Install or upgrade the Python client with `python -m pip install --upgrade datapond`, or install the released R client from [CRAN](https://cran.r-project.org/package=datapond) with `install.packages("datapond")`. Remote examples are tested with Python datapond 0.1.5 (DuckDB 1.5.4) and CRAN R datapond 0.1.0 (DuckDB 1.5.5); older DuckDB reader versions are not verified here. R 0.1.1 is a separate development version, not the CRAN release.
|
| 99 |
+
|
| 100 |
+
The examples below use the public default catalog. For limits set before attachment, use the direct DuckDB examples above; package examples here set limits immediately after connecting:
|
| 101 |
|
| 102 |
```python
|
| 103 |
import datapond
|
| 104 |
print(datapond.list())
|
| 105 |
datapond.describe('qcew', table='annual_raw')
|
| 106 |
con = datapond.connect('qcew')
|
| 107 |
+
con.execute("SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
|
| 108 |
con.sql("SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'").show()
|
| 109 |
con.close()
|
| 110 |
```
|
|
|
|
| 113 |
library(datapond)
|
| 114 |
dp_list()
|
| 115 |
con <- dp_connect('qcew')
|
| 116 |
+
DBI::dbExecute(con, "SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
|
| 117 |
dp_describe(con, table = 'annual_raw')
|
| 118 |
DBI::dbGetQuery(con, "SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'")
|
| 119 |
dp_disconnect(con)
|
|
|
|
| 137 |
dp_disconnect(con)
|
| 138 |
```
|
| 139 |
|
| 140 |
+
Verify the recorded artifact SHA-256 after downloading. In Python datapond 0.1.5 as well as 0.1.1, the optional `huggingface_hub` download path follows the repository default branch rather than the pinned URL. For an exact-version copy, download the immutable URL shown above and verify its checksum; see [consumer verification](https://github.com/ian-nason/qcew-database/blob/main/docs/CONSUMERS.md) for the tested configuration.
|
| 141 |
|
| 142 |
Default-catalog discovery and representative remote queries were verified after the registry merge. Earlier full-download checks used an isolated candidate registry. See [consumer verification](https://github.com/ian-nason/qcew-database/blob/main/docs/CONSUMERS.md) for exact client versions, paths, resource limits and download behavior. The direct URL examples above work independently of the catalog. The SQL examples below use the `qcew` catalog alias from the direct-URL quick start.
|
| 143 |
|
| 144 |
|
| 145 |
## Tables
|
| 146 |
|
| 147 |
+
One annual data row is one area × ownership group × industry × aggregation level × size class for 2025. These rows include overlapping totals and detail; choose one level before summing. Start with the `annual` view so suppressed measures become NULL.
|
| 148 |
+
|
| 149 |
| Table | Description | Rows | Columns |
|
| 150 |
|---|---|---:|---:|
|
| 151 |
| `annual_raw` | 2025 annual QCEW rows preserving all 38 source fields, numeric placeholders and disclosure flags. Mixed nested geographies, industries and ownership totals; do not sum unfiltered | 3,089,813 | 38 |
|
|
|
|
| 212 |
|
| 213 |
1. **Suppression flags are independent and partial.** Three flags (`disclosure_code`, `lq_disclosure_code`, `oty_disclosure_code`) each govern their own measures. There are 1,860,359 suppressed level rows, 1,872,172 suppressed quotient rows and 1,937,791 suppressed change rows. Suppressed rows still carry valid establishment counts. Never read a suppressed zero as zero employment or pay.
|
| 214 |
2. **Suppressed cells are inside published totals.** Summing disclosed detail gives an incomplete total; the view does not estimate or back out suppressed values. Report how many eligible cells have published values ([BLS disclosure note](https://www.bls.gov/cew/publications/employment-and-wages-annual-averages/2025/home.htm#disclosure-restrictions)).
|
| 215 |
+
3. **Rows overlap; choose one level.** National, state, county, metro and combined-area rows overlap, industry totals nest, and ownership 0 (total), 8 (total government) and 9 (UI covered excluding federal) overlap sectors 1, 2, 3 and 5. Filter on `agglvl_code` (for example 74 county/sector/ownership, 75 county/3-digit, 55 state/3-digit), not on code length.
|
| 216 |
4. **Geography moves.** Connecticut uses planning-region codes from 2024 data; codes ending `999` are unallocated. Check `areas` before fixing a study universe.
|
| 217 |
5. **Industry is 2022 NAICS.** `62` is health care and social assistance; `621` ambulatory care; `622` hospitals. Do not splice historical series without checking classification changes.
|
| 218 |
6. **Employment counts covered jobs, not people.** A worker with two covered employers counts twice; the self-employed and other uncovered groups are absent. Annual employment averages 12 monthly levels; establishments average four quarters; rounding can break exact additivity.
|