Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us
Notesclub

Exploring Explorer

explorer.livemd

Exploring Explorer

Mix.install([
  {:req, "~> 0.4.4"},
  {:explorer, "~> 0.7.1"},
  {:kino_explorer, "~> 0.1.11"}
])

Baseball

resp =
  Req.get!(
    "https://raw.githubusercontent.com/westbaystars/first-pitch-homeruns/main/balls-in-play-2022.tsv"
  )
require Explorer.DataFrame, as: DF
baseball = DF.load_csv!(resp.body, delimiter: "\t")
grouped =
  baseball
  |> DF.lazy()
  |> DF.filter(col("Pitches") == 1 and col("Result") == "home-run")
  |> DF.group_by(["Player", "Team"])
  |> DF.summarise(Result_count: count(col("Result")))
  |> DF.arrange(desc: col("Result_count"))
  |> DF.collect()
grouped
|> DF.rename(Result_count: "HR")
|> DF.arrange(desc: col("HR"))
|> DF.head(10)