-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31937a7
commit 5261368
Showing
73 changed files
with
222 additions
and
309 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
st,biden_pop,trump_pop,margin,biden_col,trump_col | ||
AK,153778,189951,-36173,0,3 | ||
AL,849624,1441170,-591546,0,9 | ||
AR,423932,760647,-336715,0,6 | ||
AZ,1672143,1661686,10457,11,0 | ||
CA,11110639,6006518,5104121,54,0 | ||
CO,1804352,1364607,439745,10,0 | ||
CT,1080831,714717,366114,7,0 | ||
DC,317323,18586,298737,3,0 | ||
DE,296268,200603,95665,3,0 | ||
FL,5297045,5668731,-371686,0,30 | ||
GA,2473633,2461854,11779,16,0 | ||
HI,366130,196864,169266,4,0 | ||
IA,759061,897672,-138611,0,6 | ||
ID,287021,554119,-267098,0,4 | ||
IL,3471915,2446891,1025024,19,0 | ||
IN,1242498,1729857,-487359,0,11 | ||
KS,570323,771406,-201083,0,6 | ||
KY,772474,1326646,-554172,0,8 | ||
LA,856034,1255776,-399742,0,8 | ||
MA,2382202,1167202,1215000,11,0 | ||
MD,1985023,976414,1008609,10,0 | ||
ME,435072,360737,74335,1,0 | ||
ME1,266376,164045,102331,1,0 | ||
ME2,168696,196692,-27996,0,2 | ||
MI,2804040,2649852,154188,15,0 | ||
MN,1717077,1484065,233012,10,0 | ||
MO,1253014,1718736,-465722,0,10 | ||
MS,539398,756764,-217366,0,6 | ||
MT,244786,343602,-98816,0,4 | ||
NC,2684292,2758775,-74483,0,16 | ||
ND,115042,235751,-120709,0,3 | ||
NE,374583,556846,-182263,0,1 | ||
NE1,132261,180290,-48029,0,1 | ||
NE2,176468,154377,22091,1,0 | ||
NE3,65854,222179,-156325,0,2 | ||
NH,424937,365660,59277,4,0 | ||
NJ,2608400,1883313,725087,14,0 | ||
NM,501614,401894,99720,5,0 | ||
NV,703486,669890,33596,6,0 | ||
NY,5244886,3251997,1992889,28,0 | ||
OH,2679165,3154834,-475669,0,17 | ||
OK,503890,1020280,-516390,0,7 | ||
OR,1340383,958448,381935,8,0 | ||
PA,3458229,3377674,80555,19,0 | ||
RI,307486,199922,107564,4,0 | ||
SC,1091541,1385103,-293562,0,9 | ||
SD,150471,261043,-110572,0,3 | ||
TN,1143711,1852475,-708764,0,11 | ||
TX,5259126,5890347,-631221,0,40 | ||
UT,560282,865140,-304858,0,6 | ||
VA,2413568,1962430,451138,13,0 | ||
VT,242820,112704,130116,3,0 | ||
WA,2369612,1584651,784961,12,0 | ||
WI,1630866,1610184,20682,10,0 | ||
WV,235984,545382,-309398,0,4 | ||
WY,73491,193559,-120068,0,3 | ||
st,biden_pop,trump_pop,margin,biden_col,trump_col,total_pop,pct,slice | ||
AK,153778,189951,-36173,0,3,343729,0.4473815127615069,-0.052618487238493106 | ||
AL,849624,1441170,-591546,0,9,2290794,0.3708862516664528,-0.12911374833354722 | ||
AR,423932,760647,-336715,0,6,1184579,0.3578756672201685,-0.1421243327798315 | ||
AZ,1672143,1661686,10457,11,0,3333829,0.5015683167912931,0.0015683167912931006 | ||
CA,11110639,6006518,5104121,54,0,17117157,0.6490937134011214,0.14909371340112143 | ||
CO,1804352,1364607,439745,10,0,3168959,0.5693831949230015,0.06938319492300149 | ||
CT,1080831,714717,366114,7,0,1795548,0.6019504908807785,0.10195049088077845 | ||
DC,317323,18586,298737,3,0,335909,0.9446695384761944,0.4446695384761944 | ||
DE,296268,200603,95665,3,0,496871,0.5962674416498447,0.09626744164984469 | ||
FL,5297045,5668731,-371686,0,30,10965776,0.48305245337858443,-0.016947546621415566 | ||
GA,2473633,2461854,11779,16,0,4935487,0.5011932966290864,0.0011932966290864044 | ||
HI,366130,196864,169266,4,0,562994,0.6503266464651488,0.15032664646514882 | ||
IA,759061,897672,-138611,0,6,1656733,0.4581673691536295,-0.04183263084637051 | ||
ID,287021,554119,-267098,0,4,841140,0.3412285707492213,-0.1587714292507787 | ||
IL,3471915,2446891,1025024,19,0,5918806,0.5865904373280693,0.08659043732806926 | ||
IN,1242498,1729857,-487359,0,11,2972355,0.4180180362036163,-0.08198196379638367 | ||
KS,570323,771406,-201083,0,6,1341729,0.4250657174436865,-0.07493428255631351 | ||
KY,772474,1326646,-554172,0,8,2099120,0.36799897099737033,-0.13200102900262967 | ||
LA,856034,1255776,-399742,0,8,2111810,0.4053555954370895,-0.09464440456291051 | ||
MA,2382202,1167202,1215000,11,0,3549404,0.6711554954014815,0.17115549540148145 | ||
MD,1985023,976414,1008609,10,0,2961437,0.6702904704709234,0.17029047047092338 | ||
ME,435072,360737,74335,2,0,795809,0.5467040458200397,0.04670404582003973 | ||
ME1,266376,164045,102331,1,0,430421,0.618873149776614,0.118873149776614 | ||
ME2,168696,196692,-27996,0,1,365388,0.4616900390817432,-0.03830996091825678 | ||
MI,2804040,2649852,154188,15,0,5453892,0.5141355934440947,0.014135593444094652 | ||
MN,1717077,1484065,233012,10,0,3201142,0.5363951364856667,0.036395136485666724 | ||
MO,1253014,1718736,-465722,0,10,2971750,0.4216417935559855,-0.07835820644401448 | ||
MS,539398,756764,-217366,0,6,1296162,0.4161501417261114,-0.08384985827388858 | ||
MT,244786,343602,-98816,0,4,588388,0.41602819907951893,-0.08397180092048107 | ||
NC,2684292,2758775,-74483,0,16,5443067,0.49315799346214184,-0.0068420065378581585 | ||
ND,115042,235751,-120709,0,3,350793,0.3279483912164724,-0.1720516087835276 | ||
NE,374583,556846,-182263,0,1,931429,0.40215947753398273,-0.09784052246601727 | ||
NE1,132261,180290,-48029,0,1,312551,0.4231661392860685,-0.0768338607139315 | ||
NE2,176468,154377,22091,1,0,330845,0.5333857244328916,0.03338572443289156 | ||
NE3,65854,222179,-156325,0,2,288033,0.22863352463085826,-0.2713664753691417 | ||
NH,424937,365660,59277,4,0,790597,0.5374887584951625,0.03748875849516253 | ||
NJ,2608400,1883313,725087,14,0,4491713,0.5807138612818762,0.08071386128187619 | ||
NM,501614,401894,99720,5,0,903508,0.5551849015171975,0.05518490151719746 | ||
NV,703486,669890,33596,6,0,1373376,0.512231173400438,0.012231173400438 | ||
NY,5244886,3251997,1992889,28,0,8496883,0.6172717689533915,0.11727176895339153 | ||
OH,2679165,3154834,-475669,0,17,5833999,0.45923302352297285,-0.04076697647702715 | ||
OK,503890,1020280,-516390,0,7,1524170,0.3305996050309349,-0.16940039496906512 | ||
OR,1340383,958448,381935,8,0,2298831,0.5830715698544173,0.08307156985441733 | ||
PA,3458229,3377674,80555,19,0,6835903,0.5058920525934906,0.005892052593490571 | ||
RI,307486,199922,107564,4,0,507408,0.6059935988395926,0.10599359883959258 | ||
SC,1091541,1385103,-293562,0,9,2476644,0.44073391250417904,-0.05926608749582096 | ||
SD,150471,261043,-110572,0,3,411514,0.365652201383185,-0.134347798616815 | ||
TN,1143711,1852475,-708764,0,11,2996186,0.38172229627933646,-0.11827770372066354 | ||
TX,5259126,5890347,-631221,0,40,11149473,0.4716927876322047,-0.02830721236779532 | ||
UT,560282,865140,-304858,0,6,1425422,0.39306394878148365,-0.10693605121851635 | ||
VA,2413568,1962430,451138,13,0,4375998,0.551546869993999,0.051546869993999045 | ||
VT,242820,112704,130116,3,0,355524,0.6829918655280656,0.18299186552806557 | ||
WA,2369612,1584651,784961,12,0,3954263,0.599255031847907,0.09925503184790696 | ||
WI,1630866,1610184,20682,10,0,3241050,0.5031906326653399,0.003190632665339921 | ||
WV,235984,545382,-309398,0,4,781366,0.3020146768607797,-0.1979853231392203 | ||
WY,73491,193559,-120068,0,3,267050,0.27519565624414905,-0.22480434375585095 |
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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
_assets/scripts/all_votes.jl → _assets/scripts/debris/all_votes.jl
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,56 @@ | ||
""" | ||
without_states(lost::Vector{String}) -> DataFrame | ||
function find_combinations(target::Int64) | ||
less_than_target = Set() | ||
equal_to_target = Set() | ||
greater_than_target = Set() | ||
for i in 1:length(swing_col) | ||
for combination in combinations(collect(keys(swing_col)), i) | ||
sum_values = sum(swing_col[state] for state in combination) | ||
if sum_values < target | ||
push!(less_than_target, combination) | ||
elseif sum_values == target | ||
push!(equal_to_target, combination) | ||
else | ||
push!(greater_than_target, combination) | ||
end | ||
end | ||
end | ||
return ( | ||
less_than_target = collect(less_than_target), | ||
equal_to_target = collect(equal_to_target), | ||
greater_than_target = collect(greater_than_target) | ||
) | ||
Find and return rows from the `outcomes` DataFrame where the `combo` column does not contain any of the states specified in the `lost` vector and where the result is "Harris". | ||
# Arguments | ||
- `lost::Vector{String}`: A vector of strings where each string represents a state to be excluded from the `combo` column. | ||
# Returns | ||
- `DataFrame`: A DataFrame containing rows that meet the criteria. | ||
# Examples | ||
```julia | ||
without_states(["PA", "NC"]) | ||
header = ["Scenario", "Electoral Votes", "Harris Total", "Trump Total", "Result"] | ||
pretty_table(without_states["PA"]; backend = Val(:html), header = header, standalone = false) | ||
""" | ||
function without_states(lost::Vector{String}) | ||
filter(row -> all(!occursin(state, row.combo) for state in lost) && row.result == "Harris", outcomes) | ||
end | ||
#------------------------------------------------------------------ | ||
""" | ||
metahelp() | ||
function electoral_map(data,kindof) | ||
if kindof == "pop" | ||
pastel = greens | ||
titular = titlecase(kindof *"ular") | ||
else | ||
pastel = purples | ||
titular = "Electoral" | ||
end | ||
shows MetaFrame structure and give example | ||
color_scale = [ | ||
(0.0, pastel[1]), | ||
(0.2, pastel[2]), | ||
(0.4, pastel[3]), | ||
(0.6, pastel[4]), | ||
(0.8, pastel[5]), | ||
(1.0, pastel[6]) | ||
] | ||
# Create the data for the choropleth map | ||
data = choropleth( | ||
locationmode = "USA-states", | ||
locations = states, | ||
z = data, | ||
colorscale = color_scale, | ||
colorbar = attr( | ||
title = titular * "Votes", | ||
#tickvals = unique(input), | ||
#ticktext = string.(unique(input)) | ||
), | ||
zmin = minimum(input), | ||
zmax = maximum(input) | ||
) | ||
|
||
# Create the layout for the map | ||
layout = Layout( | ||
title = titular * " Vote by Swing State", | ||
geo = attr( | ||
scope = "usa", | ||
projection_type = "albers usa", | ||
showlakes = true, | ||
lakecolor = "rgb(255, 255, 255)" | ||
) | ||
) | ||
# Create the plot | ||
plot(data, layout) | ||
mutable struct MetaFrame | ||
meta::Dict{Symbol, Any} | ||
data::DataFrame | ||
end | ||
# Example usage | ||
df = DataFrame(name=["John", "Jane"], age=[28, 34]) | ||
meta_info = Dict(:source => "Survey Data", :year => 2021) | ||
df = MetaFrame(meta_info, df) | ||
meta_info = Dict( | ||
:source => "Census Bureau, Current Population Survey, November 2022", | ||
:title => "Table 4c. Reported Voting and Registration of the Total Voting-Age Population, by Age, for States: November 2022", | ||
:url => "https://www.census.gov/data/tables/time-series/demo/voting-and-registration/p20-586.html", | ||
:title => "Table 4c. Reported Voting and Registration of the Total Voting-Age Population, by Age, for States: November 2022") | ||
""" | ||
function metahelp() | ||
println("Display with ?metahelp") | ||
end | ||
#------------------------------------------------------------------ | ||
# Function to determine the result based on the value of `biden` | ||
function determine_result(biden_value) | ||
if biden_value == 269 | ||
return "tie" | ||
elseif biden_value < 269 | ||
return "Trump" | ||
else | ||
return "Harris" | ||
end | ||
|
||
function radix(df::DataFrame) | ||
for col in names(df) | ||
if eltype(df[:, col]) == Int64 | ||
df[:, col] = format.(df[:, col], commas=true) | ||
end | ||
end | ||
end | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.