Jensen-holm commited on
Commit
3a0d348
·
verified ·
1 Parent(s): df38268

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -17
README.md CHANGED
@@ -14,7 +14,47 @@ This dataset contains every pitch thrown in Major League Baseball from 2015 thro
14
 
15
  This data is available through the pybaseball pacakge and the baseballr package, however it is time consuming to re scrape statcast pitch level data each time you want / need to re run your code. This dataset solves this issue using github actions to automatically update itself each week throughout the baseball season. Reading the dataset directly from the huggingface url is way faster than rescraping your data each time.
16
 
17
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  ***Pandas***
20
 
@@ -24,13 +64,6 @@ import pandas as pd
24
  df = pd.read_parquet("hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet")
25
  ```
26
 
27
- ***Duckdb***
28
-
29
- ```sql
30
- SELECT *
31
- FROM 'hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet';
32
- ```
33
-
34
  ***Polars***
35
 
36
  ```python
@@ -39,6 +72,13 @@ import polars as pl
39
  df = pl.read_parquet('hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet')
40
  ```
41
 
 
 
 
 
 
 
 
42
  ***HuggingFace Dataset***
43
 
44
  ```python
@@ -56,13 +96,7 @@ statcast_pitches <- read_parquet(
56
  )
57
  ```
58
 
59
- ## Variable Docs
60
-
61
- Documentation on the columns/features in this dataset can be found [here](https://baseballsavant.mlb.com/csv-docs).
62
-
63
- ## Updates
64
-
65
- This data set is updated once per week through GitHub Actions in [this repository](https://github.com/Jensen-holm/statcast-era-pitches). the [pybaseball](https://github.com/jldbc/pybaseball) package is used to retrieve new statcast pitch level data each monday morning at 12:00 PM ET. It is then pushed to this huggingface dataset.
66
 
67
  ## Benchmarking
68
 
@@ -72,5 +106,5 @@ This data set is updated once per week through GitHub Actions in [this repositor
72
  |---------------|-----|
73
  | 1421.103 | pybaseball |
74
  | 26.899 | polars |
75
- | 33.09332203865051 | pandas |
76
- | 68.69287300109863 | duckdb |
 
14
 
15
  This data is available through the pybaseball pacakge and the baseballr package, however it is time consuming to re scrape statcast pitch level data each time you want / need to re run your code. This dataset solves this issue using github actions to automatically update itself each week throughout the baseball season. Reading the dataset directly from the huggingface url is way faster than rescraping your data each time.
16
 
17
+ # Usage
18
+
19
+ ### With statcast_pitches package
20
+
21
+ ```bash
22
+ pip install git+https://github.com/Jensen-holm/statcast-era-pitches.git
23
+ ```
24
+
25
+ ```python
26
+ import statcast_pitches
27
+
28
+ # get bat tracking data from 2024
29
+ query_2024_bat_speed = f"""
30
+ SELECT bat_speed, swing_length
31
+ FROM pitches
32
+ WHERE
33
+ YEAR(game_date) = '2024'
34
+ AND bat_speed IS NOT NULL;
35
+ """
36
+
37
+ if __name__ == "__main__":
38
+ bat_speed_24_df = statcast_pitches.load(
39
+ query=query_2024_bat_speed,
40
+ pandas=True, # default is polars
41
+ )
42
+
43
+ print(bat_speed_24_df.head(3))
44
+ ```
45
+
46
+ output:
47
+ | | bat_speed | swing_length |
48
+ |-|------------|--------------|
49
+ | 0 | 73.61710 | 6.92448 |
50
+ | 1 | 58.63812 | 7.56904 |
51
+ | 2 | 71.71226 | 6.46088 |
52
+
53
+ **Notes**:
54
+ - If no query is specified, all data from 2015-present will be loaded into a DataFrame.
55
+ - The table in your query MUST be called 'pitches', or it will fail.
56
+
57
+ ### With HuggingFace API
58
 
59
  ***Pandas***
60
 
 
64
  df = pd.read_parquet("hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet")
65
  ```
66
 
 
 
 
 
 
 
 
67
  ***Polars***
68
 
69
  ```python
 
72
  df = pl.read_parquet('hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet')
73
  ```
74
 
75
+ ***Duckdb***
76
+
77
+ ```sql
78
+ SELECT *
79
+ FROM 'hf://datasets/Jensen-holm/statcast-era-pitches/data/statcast_era_pitches.parquet';
80
+ ```
81
+
82
  ***HuggingFace Dataset***
83
 
84
  ```python
 
96
  )
97
  ```
98
 
99
+ see the [dataset](https://huggingface.co/datasets/Jensen-holm/statcast-era-pitches) on HugingFace itself for more details.
 
 
 
 
 
 
100
 
101
  ## Benchmarking
102
 
 
106
  |---------------|-----|
107
  | 1421.103 | pybaseball |
108
  | 26.899 | polars |
109
+ | 33.093 | pandas |
110
+ | 68.692 | duckdb |