Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
/ dinah Public archive

Go library for handling MLB Statcast and Chadwick Register data

License

Notifications You must be signed in to change notification settings

fischersean/dinah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dinah

This project has migrated to sourcehut

PkgGoDev Go Report Card

The Dinah package provides data structures and fetch functionality for MLB's Statcast and Chadwick's Register datasets.

Installation

go get -u github.com/fischersean/dinah

Example

Consider we wanted to download pitch by pitch Statcast data for the month of September 2020.

package main

import (
    "fmt"
    "time"
    "github.com/fischersean/dinah/statcast"
)

func main(){
  
    d0 := time.Date(2020, time.September, 1, 0, 0, 0, 0, time.UTC)
    d1 := time.Date(2020, time.September, 30, 0, 0, 0, 0, time.UTC)

    ds, err := statcast.FromHttp(d0, d1)
  
    if err != nil {
        panic(err)
    }
  
    fmt.Println("%#v\n", ds)

}

If we wanted to patch up the MLBAM id's for the players within the Statcast data, we could pull the mapping from Chadwick's people register. It's recommended to use a local file for this. The full dataset is 45+MB and may dramatically slow execution time.

package main

import (
    "fmt"
    "time"
    "github.com/fischersean/dinah/chadwick"
)

func main(){
  
    people, err := chadwick.PeopleFromCsv("cwickpeople.csv")

    if err != nil {
        panic(err)
    }
  
    fmt.Println("%#v\n", people)
  
}

Acknowledgments

Chadwick people register

Baseball Savant