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

The Explorer demo from launch week

explorer_kino.livemd

The Explorer demo from launch week

Mix.install([
  # Kino 0.9.4, Explorer 0.5.7
  {:kino_explorer, "~> 0.1.7"},
  {:req, "~> 0.3.10"}
])

Section

Copy of the code from the Launch week video.

require Explorer.DataFrame, as: DF
alias Explorer.Series
url =
  "https://raw.githubusercontent.com/westbaystars/first-pitch-homeruns/main/balls-in-play-2022.tsv"

resp = Req.get!(url)
dataset = DF.load_csv!(resp.body, delimiter: "\t")
grouped =
  dataset
  |> DF.filter(col("Pitches") == 1 and col("Result") == "home-run")
  |> DF.group_by(["Player", "Team"])
  |> DF.summarise(Result_count: count(col("Result")))
grouped
|> DF.rename(Result_count: "HR")
|> DF.arrange(desc: col("HR"))
|> DF.head(5)
# https://github.com/westbaystars/first-pitch-homeruns/blob/main/first-pitch-homeruns.livemd

dataset
|> DF.filter_with(&Series.equal(&1["Result"], "home-run"))
|> DF.group_by(["選手", "Team"])
|> DF.summarise(Pitches: count(col("Pitches")))
|> DF.rename(Pitches: "本塁打")
|> DF.arrange(desc: col("本塁打"))
|> DF.head(30)
fruits = Explorer.Series.from_list(["apple", "mango", "banana", "orange"])
Explorer.Series.sort(fruits)
mountains =
  DF.new(
    name: ["Everest", "K2", "Aconcagua"],
    elevation: [8848, 8611, 6962]
  )
DF.filter(mountains, elevation > mean(elevation))
Explorer.Datasets.fossil_fuels()
|> Explorer.DataFrame.head(10)