Skip to content

Instantly share code, notes, and snippets.

@tjburch
Last active December 14, 2023 19:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjburch/364f244688e0942d5d4cb0ae28cfa053 to your computer and use it in GitHub Desktop.
Save tjburch/364f244688e0942d5d4cb0ae28cfa053 to your computer and use it in GitHub Desktop.
Using interoperability to load baseball data into Julia
# For pybaseball (https://github.com/jldbc/pybaseball)
using DataFrames, PyCall, CSV
pybaseball = pyimport("pybaseball")
python_df = pybaseball.statcast("2021-04-06")
julia_df = CSV.read(IOBuffer(python_df.to_csv()), DataFrame)
# For baseballr (https://billpetti.github.io/baseballr/)
using RCall
@rlibarary baseballr
julia_df = rcopy(R"baseballr::scrape_statcast_savant(start_date = '2021-04-06', end_date = '2021-04-06')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment