# Pokemon Pocket Julia Notebook

**URL:** <https://discourse.julialang.org/t/pokemon-pocket-julia-notebook/126778>\
**Category:** Offtopic\
**Tags:** dataframes, pluto, plutoui\
**Created:** [March 10, 2025, 5:22pm UTC](https://discourse.julialang.org/t/pokemon-pocket-julia-notebook/126778 "2025-03-10T17:22:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [March 10, 2025, 5:22pm UTC](https://discourse.julialang.org/t/pokemon-pocket-julia-notebook/126778/1 "2025-03-10T17:22:14Z")

</div>

I created a Pluto Notebook to view and filter [Pokemon Pocket](https://tcgpocket.pokemon.com/en-us/) 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.

[nathanrboyer/PokemonPocketCardData: Suggests Pokemon Pocket card packs you should open based on which cards you are missing.](https://github.com/nathanrboyer/PokemonPocketCardData)

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 10, 2025, 7:54pm UTC](https://discourse.julialang.org/t/pokemon-pocket-julia-notebook/126778/2 "2025-03-10T19:54:01Z")

</div>

This is very cool! Really liked how the image display “just works”

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [March 11, 2025, 4:45pm UTC](https://discourse.julialang.org/t/pokemon-pocket-julia-notebook/126778/3 "2025-03-11T16:45:44Z")

</div>

@pdeffebach You may be interested in this, and I think it relates to [Redesign of `stack` and `unstack` · Issue #3237 · JuliaData/DataFrames.jl](https://github.com/JuliaData/DataFrames.jl/issues/3237).

Yesterday I had fairly clean Split-Apply-Combine code under “Pack Information”.

```julia
@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.

```julia
@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:

```julia
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",
)

```
