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

Latest commit

 

History

History
73 lines (44 loc) · 1.64 KB

README.md

File metadata and controls

73 lines (44 loc) · 1.64 KB

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