Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arkansas State House and State Senate Elections have NULL district #7

Closed
NickCrews opened this issue Mar 4, 2024 · 2 comments
Closed

Comments

@NickCrews
Copy link

NickCrews commented Mar 4, 2024

Analyzing the data using ibis (I can give a full repro script if you really need it)

district_isnull = _.district.isnull() | (_.district == "NULL")

gb = (
    t.group_by(
        [
            "state_po",
            "office",
            "year",
        ]
    )
    .agg(
        n=_.count(),
        n_null=district_isnull.sum(),
        n_notnull=(~district_isnull).sum(),
        fraction_null=district_isnull.mean(),
    )
    .order_by(
        _.fraction_null.desc(),
        _.state_po,
        _.office,
        _.year,
    )
)
gb = gb[_.n_null > 0]
ibis.options.repr.interactive.max_rows = 100
display(gb)
ibis.options.repr.interactive.max_rows = 10

gives:

┏━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ state_po ┃ office       ┃ year  ┃ n     ┃ n_null ┃ n_notnull ┃ fraction_null ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ string   │ string       │ int64 │ int64 │ int64  │ int64     │ float64       │
├──────────┼──────────────┼───────┼───────┼────────┼───────────┼───────────────┤
│ AK       │ US HOUSE     │  2022 │  2088 │   2088 │         0 │      1.000000 │
│ AR       │ STATE HOUSE  │  2022 │ 15433 │  15433 │         0 │      1.000000 │
│ AR       │ STATE SENATE │  2022 │ 14747 │  14747 │         0 │      1.000000 │
│ LA       │ STATE HOUSE  │  2022 │   398 │    398 │         0 │      1.000000 │
│ VT       │ STATE SENATE │  2022 │   236 │     95 │       141 │      0.402542 │
│ VT       │ STATE HOUSE  │  2022 │   368 │     54 │       314 │      0.146739 │
│ IA       │ STATE HOUSE  │  2022 │  5491 │    508 │      4983 │      0.092515 │
│ IA       │ STATE SENATE │  2022 │  4031 │    256 │      3775 │      0.063508 │
│ WA       │ STATE SENATE │  2022 │  7539 │    406 │      7133 │      0.053853 │
│ WA       │ US HOUSE     │  2022 │ 16044 │    150 │     15894 │      0.009349 │
│ IN       │ STATE SENATE │  2018 │  8898 │     68 │      8830 │      0.007642 │
│ AZ       │ US HOUSE     │  2022 │  7894 │     38 │      7856 │      0.004814 │
│ UT       │ STATE HOUSE  │  2022 │  5016 │      6 │      5010 │      0.001196 │
│ MI       │ STATE SENATE │  2022 │ 22468 │     18 │     22450 │      0.000801 │
└──────────┴──────────────┴───────┴───────┴────────┴───────────┴───────────────┘

The Alaska state house races are a different easily solved issue, but the arkansas races really are a problem due to teh underlying data being insufficient.

Either we should actually track down this data, or this should be a more obvious warning in the README section on Arkansas

@sbaltzmit
Copy link
Contributor

Great catch, thanks. This is clearly a mistake, it looks as though we overlooked that the raw data files were missing district information for state house elections. I'll get someone to look into this.

@sbaltzmit
Copy link
Contributor

It should be fixed now, thanks again for noticing the missing district information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants