Skip to main content

plotting shot charts from basketball-reference.com

Project description

Shot Chart

Python module to plot NBA shot chart data and distributions for players and teams and some utilities.

This file will become your README and also the index of your documentation.

Install

pip install shot_chart

How to use

We first create a pandas dataframe from the source data.

shots_2019 = make_df(untar_data(URLs.SHOTS_2019))

Listing teams for the season

list_teams(shots_2019)
0            Atlanta
1            Orlando
183       Sacramento
184             Utah
341         Oklahoma
343     Golden State
511           Denver
512      New Orleans
675        Milwaukee
1016        Portland
1224         Phoenix
1226        Brooklyn
1412     San Antonio
1413         Memphis
1934         Toronto
2119    Philadelphia
2296       Minnesota
2477       LA Lakers
2655         Houston
2656     LA Clippers
2843       Charlotte
3017          Boston
3018      Washington
3383         Detroit
3918           Miami
5020       Cleveland
5535         Indiana
6407        New York
6410         Chicago
8473          Dallas
Name: team, dtype: object

Listing players who took at least 1 shot for a particular team

list_team_players(shots_2019, 'Portland')
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
shots_by count
2 CJ McCollum 1212
5 Damian Lillard 1158
4 Carmelo Anthony 678
7 Hassan Whiteside 676
0 Anfernee Simons 522
6 Gary Trent 349
9 Kent Bazemore 322
10 Mario Hezonja 188
13 Rodney Hood 172
15 Trevor Ariza 159
12 Nassir Little 151
14 Skal Labissière 147
1 Anthony Tolliver 117
3 Caleb Swanigan 43
8 Jaylen Hoard 32
16 Wenyen Gabriel 29
17 Zach Collins 19
11 Moses Brown 10

Plotting team shot distribution

houston = TeamShots(shots_2019,"Houston")
houston.plot_shots()

png

houston.plot_shots(date_range=((2020,1,3), (2020,1,11)))

png

Please check the extra options when using the plotting functions

portland_20191125 = TeamShots(shots_2019,"Portland")
portland_20191125.list_game_ids(2019,11,25)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
game_id winner loser
45560 201911250CHI Portland Chicago
portland_20191125.plot_shots("201911250CHI")

png

Plotting player shot distribution

player_shots = PlayerShots(shots_2019,"Anthony Davis")
player_shots.plot_shots()

png

dlo = PlayerShots(shots_2019,"D'Angelo Russell")
dlo.plot_shots()

png

dlo.plot_shots(distance_limit=(16,26),attempt="2-pointer")

png

dlo.plot_effective(most_or_least="most")

png

dlo.plot_effective(most_or_least="most",exclude=["0ft"])

png

dlo.plot_effective(most_or_least="most",min_shots="auto",exclude=['2ft'])

png

dlo.plot_effective(most_or_least="least")

png

dlo.plot_effective(most_or_least="least",min_shots="auto")

png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shot_chart-1.1.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shot_chart-1.1.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file shot_chart-1.1.1.tar.gz.

File metadata

  • Download URL: shot_chart-1.1.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for shot_chart-1.1.1.tar.gz
Algorithm Hash digest
SHA256 23925032811132157690518868dab4ac693d39028b96453d6a25060165b3132f
MD5 3df2d8d9a77fce04c9a82a9e04338cfd
BLAKE2b-256 eb1ecdc0a0174b69f75f30cc5be570333e8f225bd60fae2f15804d3a9657c5d5

See more details on using hashes here.

File details

Details for the file shot_chart-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: shot_chart-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for shot_chart-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e14868bbceaf6f1d89082fe50b0b4db3b88ca299358234ca2ffe906f33a3501b
MD5 920ba272c7527cd7ac7c52d1a4dabe39
BLAKE2b-256 f05bc96ce90059a3acdacb18c344f7578bb6ff5895d4af16c053dcc2b25aa8a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page