Skip to content

Instantly share code, notes, and snippets.

@maennchen
Created February 20, 2026 13:23
Show Gist options
  • Select an option

  • Save maennchen/4582d3ca22b168cfeec3f97c0d9a6a21 to your computer and use it in GitHub Desktop.

Select an option

Save maennchen/4582d3ca22b168cfeec3f97c0d9a6a21 to your computer and use it in GitHub Desktop.
BEAM Pushers Scripts
Mix.install([:req, :explorer])
defmodule BeamByCountry do
require Explorer.DataFrame, as: DF
def run do
# Fetch languages data
df =
Req.get!("https://github.com/github/innovationgraph/raw/refs/heads/main/data/languages.csv").body
|> Explorer.DataFrame.load_csv!()
# Calculate BEAM pushers per country and quarter
beam_by_country =
df
|> DF.filter(language in ["Elixir", "Erlang", "Gleam"])
|> DF.group_by([:iso2_code, :year, :quarter])
|> DF.summarise(beam_pushers: Explorer.Series.sum(num_pushers))
# Calculate total BEAM pushers per quarter (exclude EU to avoid double-counting)
beam_totals =
beam_by_country
|> DF.filter(iso2_code != "EU")
|> DF.group_by([:year, :quarter])
|> DF.summarise(total_beam_pushers: Explorer.Series.sum(beam_pushers))
# Join and calculate ratio
result =
beam_by_country
|> DF.join(beam_totals, on: [:year, :quarter], how: :left)
|> DF.mutate(country_ratio: beam_pushers / total_beam_pushers)
|> DF.mutate(period: cast(year, :string) <> "-Q" <> cast(quarter, :string))
|> DF.select([:iso2_code, :period, :beam_pushers, :country_ratio])
|> DF.sort_by([asc: iso2_code, asc: period])
IO.puts("BEAM Developers by Country and Quarter")
IO.puts("=======================================")
IO.inspect(result)
# Write to CSV
output_path = "beam_by_country.csv"
DF.to_csv!(result, output_path, delimiter: "\t")
IO.puts("\nCSV written to: #{output_path}")
end
end
BeamByCountry.run()
Mix.install([:req, :explorer])
defmodule BeamRatio do
require Explorer.DataFrame, as: DF
def run do
# Fetch languages data
df =
Req.get!("https://github.com/github/innovationgraph/raw/refs/heads/main/data/languages.csv").body
|> Explorer.DataFrame.load_csv!()
# Calculate total pushers per quarter (exclude EU to avoid double-counting)
totals =
df
|> DF.filter(iso2_code != "EU")
|> DF.group_by([:year, :quarter])
|> DF.summarise(total_pushers: Explorer.Series.sum(num_pushers))
# Calculate BEAM pushers per quarter (exclude EU to avoid double-counting)
beam =
df
|> DF.filter(language in ["Elixir", "Erlang", "Gleam"] and iso2_code != "EU")
|> DF.group_by([:year, :quarter])
|> DF.summarise(beam_pushers: Explorer.Series.sum(num_pushers))
# Join and calculate ratio
result =
totals
|> DF.join(beam, on: [:year, :quarter], how: :left)
|> DF.mutate(beam_pushers: Explorer.Series.fill_missing(beam_pushers, 0))
|> DF.mutate(beam_ratio: beam_pushers / total_pushers)
|> DF.mutate(period: cast(year, :string) <> "-Q" <> cast(quarter, :string))
|> DF.select([:period, :total_pushers, :beam_pushers, :beam_ratio])
|> DF.sort_by([asc: period])
IO.puts("BEAM Language Ratio by Location and Quarter")
IO.puts("============================================")
IO.inspect(result)
# Write to CSV
output_path = "beam_ratio_by_location.csv"
DF.to_csv!(result, output_path, delimiter: "\t")
IO.puts("\nCSV written to: #{output_path}")
end
end
BeamRatio.run()
@maennchen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment