- Subject: A field that is grouped on; analogous to SQL's "GROUP BY"
clause. - Split: A filter used to restrict a dataset; analogous to SQL's "WHERE"
clause.- vs LHH: "versus left-handed hitters"
- vs RHH: "versus right-handed hitters"
- vs LHP: "versus left-handed pitchers"
- vs RHP: "versus right-handed pitchers"
- Stat: A metric that is calculated from the aggregated data. There are
four basic stats to be calculated that should be familiar to any baseball fan.- AVG
- OBP
- SLG
- OPS
- Create a GitLab account (if you don't already have one).
- Clone this repository to your machine.
- Install it using
pip install -r requirements.txt
- Modify run.py to perform the following steps when called via
python run.py
:- Read in
./data/raw/pitchdata.csv
- Perform grouping/aggregations of each combination from
./data/reference/combinations.txt
to create tables/dataframes. - Round the stat to a max of three decimal places.
- Only include subjects with PA >= 25.
- Combine each individual table/dataframe into a single one with the
following column headers:- SubjectId (e.g. 108, 119, etc)
- Stat (e.g. the name of the stat "AVG", "OBP", etc.)
- Split (e.g. "vs LHP", "vs RHH", etc.)
- Subject (e.g. "HitterId", "PitcherTeamId", etc.)
- Value (e.g. the value of the Stat 0.350, 1.03, 0.5, etc)
- Sort the table/dataframe on the first four columns (each in ascending
order). - Save the csv to
./data/processed/output.csv
- Read in
- Run the test suite by opening a command-line, cd in to the repo, and running
the following command:pytest -v
- Upload to a new repository under your own GitLab/GitHub/BitBucket account.
- Email the link to your repository to Andrew Pautz (pautz@inside-edge.com).
Let's take the first combination to be processed from combinations.txt:
AVG,HitterId,vs RHP
... the equivalent SQL would look something like:
SELECT
HitterId AS SubjectId,
'AVG' AS Stat,
'vs RHP' AS Split,
'HitterId' AS Subject,
ROUND(CAST(SUM(H) AS FLOAT)/SUM(AB), 3) AS Value
FROM ./data/raw/pitchdata.csv
WHERE PitcherSide = 'R'
GROUP BY HitterId
HAVING SUM(PA) >= 50
Your submission will be scored on 5 aspects:
- Accuracy: The output data must be 100% accurate.
- Readability: The easier it is to understand, the better.
- Performant: It should ideally take just 1-2 seconds to finish.
- Development Time: Try to submit within a day.
- Installable: Make it installable via
pip install -r requirements.txt
- Use any third party libraries you'd like so long as they're installed via
the requirements.txt file. We use pandas heavily, but if you're more
comfortable using numpy or something entirely else feel free to do so. - You don't need to limit your modifications to run.py. You can add/edit any
other file in the repo with the exception of anything in:- ./tests
- ./data/raw
- ./data/reference
- Code should generally be pep8 compliant.
- Documentation isn't required, but wouldn't be frowned upon.
- If you need to go a bit over 80 chars ... no problem.