Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review fixes #59

Merged
merged 4 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
name = "pysketball"
version = "2.0.0"
description = "This is a Python package that scraps tabular ESPN NBA data from https://www.espn.com/nba/stats/player/_/season/2019/seasontype/2 and processes it"
authors = ["Andres Pitta <[email protected]>"]
authors = [
"Andres Pitta <[email protected]>",
"Anand Shankar, <[email protected]>",
"Carlina Kim, <[email protected]>",
"Kenneth Foo, <[email protected]>"
]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/UBC-MDS/pysketball"
Expand Down
3 changes: 2 additions & 1 deletion pysketball/nba_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def nba_scraper(season_year, season_type="regular", csv_path=None):
season_year : int
An integer input of the year of interest for the NBA season.
season_type : string
A string input of the NBA season type (either "regular" or playoff).
A string input of the NBA season type (either "regular" or
"postseason").
Default is "regular".
csv_path_name : string
A string input stating the path to store the scraped csv file and
Expand Down
23 changes: 22 additions & 1 deletion pysketball/nba_team_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ def nba_team_stats(nba_data, stats_filter=None, teams_filter=None,
stats_filter = ['GP', '3PM', 'FT%'],
teams_filter = ['UTAH', 'PHX', 'DET'],
positions_filter = ['C', 'PG'])
{'GP': count mean std min 25% 50% 75% max
Team POS
DET C 2.0 73.5 7.778175 68.0 70.75 73.5 76.25 79.0
PG 1.0 82.0 NaN 82.0 82.00 82.0 82.00 82.0
PHX C 1.0 71.0 NaN 71.0 71.00 71.0 71.00 71.0
UTAH C 1.0 81.0 NaN 81.0 81.00 81.0 81.00 81.0
PG 1.0 68.0 NaN 68.0 68.00 68.0 68.00 68.0,
'3PM': count mean std min 25% 50% 75% max
Team POS
DET C 2.0 0.05 0.070711 0.0 0.025 0.05 0.075 0.1
PG 1.0 2.10 NaN 2.1 2.100 2.10 2.100 2.1
PHX C 1.0 0.00 NaN 0.0 0.000 0.00 0.000 0.0
UTAH C 1.0 0.00 NaN 0.0 0.000 0.00 0.000 0.0
PG 1.0 1.20 NaN 1.2 1.200 1.20 1.200 1.2,
'FT%': count mean std min 25% 50% 75% max
Team POS
DET C 2.0 68.6 13.57645 59.0 63.8 68.6 73.4 78.2
PG 1.0 86.4 NaN 86.4 86.4 86.4 86.4 86.4
PHX C 1.0 74.6 NaN 74.6 74.6 74.6 74.6 74.6
UTAH C 1.0 63.6 NaN 63.6 63.6 63.6 63.6 63.6
PG 1.0 85.5 NaN 85.5 85.5 85.5 85.5 85.5}
"""
# Check if nba_data is a DataFrame
if not isinstance(nba_data, pd.DataFrame):
Expand Down Expand Up @@ -109,6 +130,6 @@ def nba_team_stats(nba_data, stats_filter=None, teams_filter=None,
stats_filter = [stat for stat in stats_filter if stat not in (
'NAME', 'TEAM', 'POS')]
for stat in stats_filter:
stats[stat] = nba_data.groupby(group_by).describe()[stat]
stats[stat] = nba_data.groupby(group_by).describe().round(3)[stat]

return stats