I created a Pluto Notebook to view and filter Pokemon Pocket cards. I think it ended up looking pretty nice, rendering images of the cards inside the data frames. I thought I would share it here in case anyone else plays the game or finds it illustrative.
7 Likes
This is very cool! Really liked how the image display βjust worksβ
1 Like
@pdeffebach You may be interested in this, and I think it relates to Redesign of stack
and unstack
Β· Issue #3237 Β· JuliaData/DataFrames.jl.
Yesterday I had fairly clean Split-Apply-Combine code under βPack Informationβ.
@chain desired_cards_unpacked begin
groupby(:pack)
@combine(
$"Desired Cards" = [copy(:image)],
:Total = $nrow,
:β = count(==("β"), :rarity),
:ββ = count(==("ββ"), :rarity),
:βββ = count(==("βββ"), :rarity),
:ββββ = count(==("ββββ"), :rarity),
:β = count(==("β"), :rarity),
:ββ = count(==("ββ"), :rarity),
:βββ = count(==("βββ"), :rarity),
:β = count(==("β"), :rarity),
)
@rselect!(:Pack = [pack_images[:pack]], $(Not(:pack)))
sort!([:Total, :β, :ββ, :βββ, :ββββ, :β, :ββ, :βββ, :β], rev=true)
end
Today I figured I could clean up and shorten the code by removing the hard-coded rarity symbols. But Iβm not sure this equivalent is better.
@chain desired_cards_unpacked begin
groupby([:pack, :rarity])
combine(
:image => (x -> [copy(x)]),
nrow,
renamecols = false,
)
sort!(:rarity)
unstack(:rarity, :nrow, fill=0)
groupby(:pack)
combine(
:image => (x -> [reduce(vcat, x)]),
Not(:pack, :image) .=> sum,
renamecols = false,
)
transform!(Not(:pack, :image) => (+) => :total)
select!(
:pack => ByRow(x -> [pack_images[x]]) => "Pack",
:image => "Desired Cards",
:total => "Total",
Not(:pack, :image, :total),
)
sort!("Total", rev=true)
end
I ended up abandoning DataFramesMeta.jl in this cell because I was adding more escaping characters than I was saving, and I couldnβt get renamecols=false
to work. Also, now I am Split-Apply-Combine-Sorting twice. Do you know a better way?
Example data is below if you donβt want to download the Pluto notebook:
desired_cards_unpacked = DataFrame(
[
"A1" 41 "Arcanine ex" "ββββ" "Pikachu" "150" "Image 1"
"A1" 45 "Flareon" "βββ" "Charizard" "120" "Image 2"
"A1" 125 "Hypno" "βββ" "Pikachu" "100" "Image 3"
"A1" 203 "Kangaskhan" "βββ" "Charizard" "100" "Image 4"
"A1" 267 "Misty" "ββ" "Pikachu" missing "Image 5"
"A1" 275 "Articuno ex" "ββ" "Mewtwo" "140" "Image 6"
"A1a" 46 "Aerodactyl ex" "ββββ" "Mew" "140" "Image 7"
"A1a" 72 "Vaporeon" "β" "Mew" "120" "Image 8"
"A1a" 84 "Aerodactyl ex" "ββ" "Mew" "140" "Image 9"
"A2" 24 "Magmortar" "βββ" "Palkia" "130" "Image 10"
],
["series", "number", "name", "rarity", "pack", "health", "image"],
)
pack_images = Dict(
"Pikachu" => "Pikachu",
"Charizard" => "Charizard",
"Mewtwo" => "Mewtwo",
"Mew" => "Mew",
"Palkia" => "Palkia",
"Dialga" => "Dialga",
)