{"id":20942467,"url":"https://github.com/bdilday/pychadwick","last_synced_at":"2025-05-13T23:32:55.814Z","repository":{"id":54643493,"uuid":"204746115","full_name":"bdilday/pychadwick","owner":"bdilday","description":"Python package to interface with chadwick library","archived":false,"fork":false,"pushed_at":"2023-07-06T12:40:03.000Z","size":349,"stargazers_count":9,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-18T12:31:12.096Z","etag":null,"topics":["baseball","baseball-data","c","python","retrosheet","retrosheet-tools"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdilday.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-27T16:37:54.000Z","updated_at":"2024-06-20T10:20:38.000Z","dependencies_parsed_at":"2024-11-18T23:33:22.874Z","dependency_job_id":"c6bbbe14-d026-4efd-8b91-0300aab07e62","html_url":"https://github.com/bdilday/pychadwick","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.36363636363636365","last_synced_commit":"08e302e97153c58646ef9ea9ca96a4758ff6e735"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdilday%2Fpychadwick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdilday%2Fpychadwick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdilday%2Fpychadwick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdilday%2Fpychadwick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdilday","download_url":"https://codeload.github.com/bdilday/pychadwick/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043218,"owners_count":22004912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["baseball","baseball-data","c","python","retrosheet","retrosheet-tools"],"created_at":"2024-11-18T23:27:17.901Z","updated_at":"2025-05-13T23:32:53.650Z","avatar_url":"https://github.com/bdilday.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pychadwick\n\nA Python package to interface with the `Chadwick` libray.  \n`Chadwick` is a set of tools for parsing retrosheet data\nand is available at \n\nhttp://chadwick.sourceforge.net/doc/index.html\n\nhttps://github.com/chadwickbureau/chadwick\n\n## Features\n\nAs of now this package supports retrosheet event data only.\n\n## Installation\n\n```bash\n$ pip install pychadwick\n```\n\n## Example use\n\n#### Python replacement for cwevent\n\nWhen you install `pychadwick`, it will install a \nPython exe that mimic the `cwevent` exe from the \nchadwick project. It reads a set of event files and \nprints them out in csv format to `stdout`.\n\n\nThis downloads a fresh copy of the retrosheet event files,\nand parses them with 7 CPUs\n\n```bash\n$ time pycwevent -n 7  \u003e /tmp/events1.csv\nstderr: data_root not given as argument, downloading fresh copy of retrosheet events...\nstderr: found 2254 files\nWarning: Invalid integer value 'b'\n\nreal\t3m14.517s\nuser\t12m18.104s\nsys\t0m25.264s\n\n$ wc -l /tmp/events1.csv \n13976191 /tmp/events1.csv\n```\n\nThis uses a pre-downloaded copy of the retrosheet event files,\nwith 7 CPUs\n\n```bash\n$ time pycwevent -n 7 --data-root /tmp/retrosheet-master/event/regular/ \u003e /tmp/events2.csv\nstderr: found 2254 files\nWarning: Invalid integer value 'b'\n\nreal\t1m57.499s\nuser\t9m52.236s\nsys\t0m17.672s\n\n$ wc -l /tmp/events2.csv \n13976184 /tmp/events2.csv\n```\n\n### Python interface to cwevent\n\n#### Load events\n\nLoad events for a game from a file stored on the web\n\n```python\n\n\u003e\u003e\u003e from pychadwick.chadwick import Chadwick                                                                                    \n\n\u003e\u003e\u003e chadwick = Chadwick()                                                                                                       \n\n\u003e\u003e\u003e file_path = \"https://raw.githubusercontent.com/chadwickbureau/retrosheet/master/event/regular/1982OAK.EVA\" \n\n\u003e\u003e\u003e games = chadwick.games(file_path)                                                                                           \n\n\u003e\u003e\u003e game = next(games)                                                                                                          \n\n\u003e\u003e\u003e df = chadwick.game_to_dataframe(game)                                                                                       \n\n\u003e\u003e\u003e df                                                                                                                           \n         GAME_ID AWAY_TEAM_ID  INN_CT  BAT_HOME_ID  ...  ASS9_FLD_CD  ASS10_FLD_CD  UNKNOWN_OUT_EXC_FL UNCERTAIN_PLAY_EXC_FL\n0   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n1   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n2   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n3   OAK198204060          CAL       1            1  ...            0             0                   F                     F\n4   OAK198204060          CAL       1            1  ...            0             0                   F                     F\n..           ...          ...     ...          ...  ...          ...           ...                 ...                   ...\n81  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n82  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n83  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n84  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n85  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n\n[86 rows x 159 columns]\n```\n\nLoad events for a game from a local file\n\n```python\n\n\u003e\u003e\u003e file_path = \" /tmp/retrosheet-master/event/regular/1982OAK.EVA\"\n\n\u003e\u003e\u003e games = chadwick.games(file_path)                                                                                           \n\n\u003e\u003e\u003e game = next(games)                                                                                                          \n\n\u003e\u003e\u003e df = chadwick.game_to_dataframe(game)                                                                                       \n\n\u003e\u003e\u003e df                                                                                                                           \n         GAME_ID AWAY_TEAM_ID  INN_CT  BAT_HOME_ID  ...  ASS9_FLD_CD  ASS10_FLD_CD  UNKNOWN_OUT_EXC_FL UNCERTAIN_PLAY_EXC_FL\n0   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n1   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n2   OAK198204060          CAL       1            0  ...            0             0                   F                     F\n3   OAK198204060          CAL       1            1  ...            0             0                   F                     F\n4   OAK198204060          CAL       1            1  ...            0             0                   F                     F\n..           ...          ...     ...          ...  ...          ...           ...                 ...                   ...\n81  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n82  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n83  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n84  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n85  OAK198204060          CAL      11            1  ...            0             0                   F                     F\n\n[86 rows x 159 columns]\n```\n\nCheck which columns are defined\n\n```python\n\u003e\u003e\u003e  chadwick.all_headers\n```\n\nCheck which columns are enabled\n\n```python\n\u003e\u003e\u003e  chadwick.active_headers\n```\n\nDisable all columns, and add only `GAME_ID` and `BAT_ID`\n\n```python\n\u003e\u003e\u003e _ = [chadwick.unset_event_field(e) for e in chadwick.all_headers]                                                          \n\n\u003e\u003e\u003e chadwick.active_headers                                                                                                    \n[]\n\n\u003e\u003e\u003e chadwick.set_event_field(\"GAME_ID\")                                                                                        \n\n\u003e\u003e\u003e chadwick.set_event_field(\"BAT_ID\")                                                                                         \n\n\u003e\u003e\u003e games = chadwick.games(file_path)                                                                                          \n\n\u003e\u003e\u003e  game = next(games)                                                                                                         \n\n\u003e\u003e\u003e df = chadwick.game_to_dataframe(game)                                                                                      \n\n\u003e\u003e\u003e df\n\n         GAME_ID    BAT_ID\n0   OAK198204060  burlr001\n1   OAK198204060  lynnf001\n2   OAK198204060  carer001\n3   OAK198204060  hendr001\n4   OAK198204060  murpd002\n..           ...       ...\n81  OAK198204060  meyed001\n82  OAK198204060  armat001\n83  OAK198204060  grosw001\n84  OAK198204060  spenj101\n85  OAK198204060  loped001\n\n[86 rows x 2 columns]\n```\n\nActivate all the columns again\n\n```python\n\u003e\u003e\u003e chadwick.set_all_headers()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdilday%2Fpychadwick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdilday%2Fpychadwick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdilday%2Fpychadwick/lists"}