diff --git a/docs/source/conf.py b/docs/source/conf.py index 5c4ae71..185dae3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -48,18 +48,18 @@ master_doc = 'index' # General information about the project. -project = u'sportsref' -copyright = u'2016, Matt Goldberg' -author = u'Matt Goldberg' +project = 'sportsref' +copyright = '2016, Matt Goldberg' +author = 'Matt Goldberg' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'' +version = '' # The full version, including alpha/beta/rc tags. -release = u'' +release = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -129,8 +129,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'sportsref.tex', u'sportsref Documentation', - u'Matt Goldberg', 'manual'), + (master_doc, 'sportsref.tex', 'sportsref Documentation', + 'Matt Goldberg', 'manual'), ] @@ -139,7 +139,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'sportsref', u'sportsref Documentation', + (master_doc, 'sportsref', 'sportsref Documentation', [author], 1) ] @@ -150,7 +150,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'sportsref', u'sportsref Documentation', + (master_doc, 'sportsref', 'sportsref Documentation', author, 'sportsref', 'One line description of project.', 'Miscellaneous'), ] diff --git a/requirements.txt b/requirements.txt index 6f726ff..c8c86ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,105 +1,61 @@ appdirs==1.4.3 appnope==0.1.0 -argh==0.26.2 -backports-abc==0.5 -backports.shutil-get-terminal-size==1.0.0 -bleach==1.5.0 -boltons==17.0.0 -boto3==1.4.3 -botocore==1.4.93 -certifi==2016.9.26 -click==6.7 -cloudpickle==0.2.2 -configparser==3.5.0 -cssselect==1.0.0 -cycler==0.10.0 -dask==0.13.0 -decorator==4.0.10 -distributed==1.15.0 -docutils==0.13.1 -entrypoints==0.2.2 -enum34==1.1.6 -functools32==3.2.3.post2 +bleach==2.1.2 +boltons==17.2.0 +certifi==2018.1.18 +chardet==3.0.4 +cssselect==1.0.3 +decorator==4.2.1 +entrypoints==0.2.3 future==0.16.0 -futures==3.0.5 -graphviz==0.5.2 -HeapDict==1.0.0 -html5lib==0.9999999 -invoke==0.14.0 -ipdb==0.10.1 -ipykernel==4.5.2 -ipython==5.1.0 -ipython-genutils==0.1.0 -ipywidgets==5.2.2 -Jinja2==2.8.1 -jmespath==0.9.0 -jsonschema==2.5.1 +html5lib==1.0.1 +idna==2.6 +ipdb==0.10.3 +ipykernel==4.8.0 +ipython==6.2.1 +ipython-genutils==0.2.0 +ipywidgets==7.1.1 +jedi==0.11.1 +Jinja2==2.10 +jsonschema==2.6.0 jupyter==1.0.0 -jupyter-client==4.4.0 -jupyter-console==5.0.0 -jupyter-core==4.2.1 -livereload==2.5.0 -locket==0.2.0 -lxml==3.7.1 -MarkupSafe==0.23 -matplotlib==2.0.0 -mementos==1.2.6 -mistune==0.7.3 -msgpack-python==0.4.8 -nbconvert==5.0.0 -nbformat==4.2.0 -notebook==4.3.1 -numexpr==2.6.2 -numpy==1.12.0 -packaging==16.8 -pandas==0.19.2 -pandocfilters==1.4.1 -partd==0.3.7 -pathlib2==2.1.0 -pathtools==0.1.2 -patsy==0.4.1 -pexpect==4.2.1 +jupyter-client==5.2.2 +jupyter-console==5.2.0 +jupyter-core==4.4.0 +lxml==4.1.1 +MarkupSafe==1.0 +mementos==1.2.8 +mistune==0.8.3 +nbconvert==5.3.1 +nbformat==4.4.0 +notebook==5.4.0 +numexpr==2.6.4 +numpy==1.14.0 +pandas==0.22.0 +pandocfilters==1.4.2 +parso==0.1.1 +pexpect==4.3.1 pickleshare==0.7.4 -pluggy==0.4.0 -port-for==0.3.1 -prompt-toolkit==1.0.9 -psutil==5.0.1 -ptyprocess==0.5.1 -Pweave==0.25 -py==1.4.32 -Pygments==2.1.3 -pyparsing==2.1.10 -pyquery==1.2.17 -pytest==3.0.5 -python-dateutil==2.6.0 -pytz==2016.10 -PyYAML==3.12 -pyzmq==16.0.2 -qtconsole==4.2.1 -requests==2.13.0 -s3fs==0.0.8 -s3transfer==0.1.10 -scikit-learn==0.18.1 -scipy==0.18.1 +prompt-toolkit==1.0.15 +ptyprocess==0.5.2 +Pygments==2.2.0 +pyquery==1.4.0 +python-dateutil==2.6.1 +pytz==2017.3 +pyzmq==16.0.4 +qtconsole==4.3.1 +requests==2.18.4 +scipy==1.0.0 +Send2Trash==1.4.2 simplegeneric==0.8.1 -singledispatch==3.4.0.3 -six==1.10.0 -sklearn==0.0 -sortedcollections==0.4.2 -sortedcontainers==1.5.7 -sphinx-autobuild==0.6.0 --e git+git@github.com:mdgoldberg/sportsref.git@cfb9edb89da9eeb99ef54d149d32f4e99b7e2087#egg=sportsref -statsmodels==0.6.1 -subprocess32==3.2.7 -tblib==1.3.0 -terminado==0.6 -testpath==0.3 -toolz==0.8.2 -tornado==4.4.2 -tox==2.5.0 -traitlets==4.3.1 -virtualenv==15.1.0 -watchdog==0.8.3 +six==1.11.0 +sportsref==0.9.1 +terminado==0.8.1 +testpath==0.3.1 +tornado==4.5.3 +traitlets==4.3.2 +urllib3==1.22 wcwidth==0.1.7 -widgetsnbextension==1.2.6 -zict==0.1.1 +webencodings==0.5.1 +widgetsnbextension==3.1.3 +yapf==0.20.1 diff --git a/setup.py b/setup.py index b64432a..5226a46 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup(name='sportsref', - version='0.9.1', + version='0.10.0', description='Scraping data from sports-reference.com and related sites', url='https://github.com/mdgoldberg/sportsref', author='Matt Goldberg', diff --git a/sportsref/euro/__init__.py b/sportsref/euro/__init__.py new file mode 100644 index 0000000..b9ff399 --- /dev/null +++ b/sportsref/euro/__init__.py @@ -0,0 +1,22 @@ +from . import boxscores +from . import pbp +from . import seasons +from . import teams + +from .boxscores import BoxScore +from .seasons import Season +from .teams import Team +from .players import Player + +BASE_URL = 'http://www.basketball-reference.com/euro' + +LEAGUE_IDS = ['greek-basket-league','eurocup','spain-liga-acb','italy-basket-serie-a','france-lnb-pro-a','euroleague'] + +__all__ = [ + 'LEAGUE_IDS', + 'BASE_URL', + 'boxscores', 'BoxScore', + 'seasons', 'Season', + 'teams', 'Team', + 'players', 'Player', +] diff --git a/sportsref/euro/boxscores.py b/sportsref/euro/boxscores.py new file mode 100644 index 0000000..e6f3243 --- /dev/null +++ b/sportsref/euro/boxscores.py @@ -0,0 +1,167 @@ +import future +import future.utils + +import datetime +import re + +import numpy as np +import pandas as pd +from pyquery import PyQuery as pq + +import sportsref + + +class BoxScore( + future.utils.with_metaclass(sportsref.decorators.Cached, object) +): + + def __init__(self, boxscore_id): + self.boxscore_id = boxscore_id + + def __eq__(self, other): + return self.boxscore_id == other.boxscore_id + + def __hash__(self): + return hash(self.boxscore_id) + + def __repr__(self): + return 'BoxScore({})'.format(self.boxscore_id) + + @sportsref.decorators.memoize + def get_main_doc(self): + url = ('{}/boxscores/{}.htm' + .format(sportsref.euro.BASE_URL, self.boxscore_id)) + doc = pq(sportsref.utils.get_html(url)) + return doc + + @sportsref.decorators.memoize + def get_subpage_doc(self, page): + url = (sportsref.nba.BASE_URL + + '/boxscores/{}/{}.htm'.format(page, self.boxscore_id)) + doc = pq(sportsref.utils.get_html(url)) + return doc + + @sportsref.decorators.memoize + def date(self): + """Returns the date of the game. See Python datetime.date documentation + for more. + :returns: A datetime.date object with year, month, and day attributes. + """ + match = re.match(r'(\d{4})-(\d{2})-(\d{2})', self.boxscore_id) + year, month, day = list(map(int, match.groups())) + return datetime.date(year=year, month=month, day=day) + + @sportsref.decorators.memoize + def weekday(self): + days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', + 'Saturday', 'Sunday'] + date = self.date() + wd = date.weekday() + return days[wd] + + @sportsref.decorators.memoize + def get_raw_id(self, home): + """Returns home team ID. + :returns: string representing home team's ID. + """ + doc = self.get_main_doc() + div = doc('.scorebox') + + a_list = [] + for a in div('a').items(): + href = a.attr('href') + if 'teams' in href: + a_list.append(href) + + if home: + return a_list[1] + return a_list[0] + + @sportsref.decorators.memoize + def get_score(self, home): + """Returns home team ID. + :returns: string representing home team's ID. + """ + doc = self.get_main_doc() + div = doc('.scorebox') + + scores = [] + for d in div('.score').items(): + scores.append(int(d.text())) + + if home: + return scores[1] + return scores[0] + + + @sportsref.decorators.memoize + def home(self): + """Returns home team ID. + :returns: string representing home team's ID. + """ + + l = self.get_raw_id(home=True) + return l.split('/')[3] + + @sportsref.decorators.memoize + def away(self): + """Returns away team ID. + :returns: string representing away team's ID. + """ + + l = self.get_raw_id(home=False) + return l.split('/')[3] + + @sportsref.decorators.memoize + def home_score(self): + """Returns score of the home team. + :returns: int of the home score. + """ + return self.get_score(home=True) + + @sportsref.decorators.memoize + def away_score(self): + """Returns score of the away team. + :returns: int of the away score. + """ + return self.get_score(home=False) + + @sportsref.decorators.memoize + def winner(self): + """Returns the team ID of the winning team. Returns NaN if a tie.""" + hmScore = self.home_score() + awScore = self.away_score() + if hmScore > awScore: + return self.home() + elif hmScore < awScore: + return self.away() + else: + return None + + @sportsref.decorators.memoize + def season(self): + """ + Returns the year ID of the season in which this game took place. + + :returns: An int representing the year of the season. + """ + l = self.get_raw_id(home=True) + return l.split('/')[4].replace('.html','') + + @sportsref.decorators.memoize + def get_home_stats(self): + doc = self.get_main_doc() + table = doc('table#{}'.format('box-score-home')) + df = sportsref.utils.parse_table(table) + + return df + + @sportsref.decorators.memoize + def get_away_stats(self): + doc = self.get_main_doc() + table = doc('table#{}'.format('box-score-visitor')) + df = sportsref.utils.parse_table(table) + + return df + + diff --git a/sportsref/euro/players.py b/sportsref/euro/players.py new file mode 100644 index 0000000..b339eec --- /dev/null +++ b/sportsref/euro/players.py @@ -0,0 +1,212 @@ +import future +import future.utils + +import datetime +import re +import requests + +import numpy as np +from pyquery import PyQuery as pq + +import sportsref + +__all__ = [ + 'Player', +] + + +class Player(future.utils.with_metaclass(sportsref.decorators.Cached, object)): + + """Each instance of this class represents an Euro player, uniquely + identified by a player ID. The instance methods give various data available + from the player's Sports Reference player page.""" + + def __init__(self, player_id): + self.player_id = player_id + self.main_url = self.get_main_url(player_id) + + def get_main_url(self, player_id): + return (sportsref.euro.BASE_URL + '/players/{0}.htm').format(player_id) + + def __eq__(self, other): + return self.player_id == other.player_id + + def __hash__(self): + return hash(self.player_id) + + def __repr__(self): + return 'Player({})'.format(self.player_id) + + def __str__(self): + return self.name() + + @sportsref.decorators.memoize + def get_main_doc(self, level='B'): + #Need to have a level option this deep in process because all vs club vs tourney means a completely different doc for euro, instead of nba which is just a different table and same doc + + player_id = self.player_id + if level == 'C': + player_id += '-club' + if level == 'E': + player_id += '-tournament' + return pq(sportsref.utils.get_html(self.get_main_url(player_id))) + + @sportsref.decorators.memoize + def get_gamelog_doc(self, year, league): + url = '{}/pgl_euro.cgi?player_id={}&year_id={}&lg_id={}'.format(sportsref.euro.BASE_URL, self.player_id, year, league) + return pq(sportsref.utils.get_html(url)) + + @sportsref.decorators.memoize + def available_gamelogs(self): + + tup_list = [] + doc = self.get_main_doc() + for li in doc('#bottom_nav_container')('ul')('li').items(): + href = li('a').attr('href') + if href and 'pgl_euro.cgi?' in href: + tup_list.append((int(re.search(r'year_id=(.*?)&', href).group(1)), re.search(r'lg_id=(.*?)$', href).group(1))) + + return tup_list + + @sportsref.decorators.memoize + def name(self): + """Returns the name of the player as a string.""" + doc = self.get_main_doc() + return doc('h1[itemprop="name"]').text().replace(' Europe Stats', '') + + @sportsref.decorators.memoize + def age(self, year, month=2, day=1): + """Returns the age of the player on a given date. + + :year: int representing the year. + :month: int representing the month (1-12). + :day: int representing the day within the month (1-31). + :returns: Age in years as a float. + """ + doc = self.get_main_doc() + date_string = doc('span[itemprop="birthDate"]').attr('data-birth') + regex = r'(\d{4})\-(\d{2})\-(\d{2})' + date_args = list(map(int, re.match(regex, date_string).groups())) + birth_date = datetime.date(*date_args) + age_date = datetime.date(year=year, month=month, day=day) + delta = age_date - birth_date + age = delta.days / 365. + return age + + @sportsref.decorators.memoize + def position(self): + """Returns the position of a player (note: not consistently coded in bballref) + :returns: Position + """ + doc = self.get_main_doc() + raw = doc('p:contains("Position:")').text() + pos = raw.split()[1] + return pos + + @sportsref.decorators.memoize + def nba_id(self): + """Returns the euro player's NBA bballref id if they played in the NBA, None if they haven't + :returns: NBA_ID + """ + doc = self.get_main_doc() + p = doc('p:contains("NBA Career:")') + href = '' + for a in p('a').items(): + href = a.attr('href') + + if href == '': + return None + + nba_id = href.split('/')[3].replace('.html', '') + + return nba_id + + @sportsref.decorators.memoize + def height(self): + """Returns the player's height (in inches). + :returns: An int representing a player's height in inches. + """ + doc = self.get_main_doc() + raw = doc('span[itemprop="height"]').text() + try: + feet, inches = list(map(int, raw.split('-'))) + return feet * 12 + inches + except ValueError: + return None + + @sportsref.decorators.memoize + def weight(self): + """Returns the player's weight (in pounds). + :returns: An int representing a player's weight in pounds. + """ + doc = self.get_main_doc() + raw = doc('span[itemprop="weight"]').text() + try: + weight = re.match(r'(\d+)lb', raw).group(1) + return int(weight) + except ValueError: + return None + + @sportsref.decorators.kind_rpb(include_type=True) + def _get_stats_table(self, table_id, kind='R', level='B', summary=False): + """Gets a stats table from the player page; helper function that does + the work for per-game, per-36-min, etc. stats. + + :table_id: the ID of the HTML table. + :kind: specifies regular season, playoffs. One of 'R', 'P'. + Defaults to 'R'. + :level: specifies Club play (C), Eurocup/Euroleague play (E), or Both (B) - defaults to B + :returns: A DataFrame of stats. + """ + doc = self.get_main_doc(level=level) + if level == 'E': + table_id = 'table#{}EUR0'.format(table_id) + elif level == 'C': + table_id = 'table#{}{}'.format(table_id, 'CLU1' if kind == 'P' else 'CLU0') + else: + table_id = 'table#{}{}'.format(table_id, 'ALL1' if kind == 'P' else 'ALL0') + + table = doc(table_id) + df = sportsref.utils.parse_table(table, flatten=(not summary), footer=summary) + return df + + @sportsref.decorators.memoize + def stats_per_game(self, kind='R', level='B', summary=False): + """Returns a DataFrame of per-game box score stats.""" + return self._get_stats_table('per_game', kind=kind, level=level, summary=summary) + + @sportsref.decorators.memoize + def stats_totals(self, kind='R', level='B', summary=False): + """Returns a DataFrame of total box score statistics by season.""" + return self._get_stats_table('totals', kind=kind, level=level, summary=summary) + + @sportsref.decorators.memoize + def stats_per36(self, kind='R', level='B', summary=False): + """Returns a DataFrame of per-36-minutes stats.""" + return self._get_stats_table('per_minute', kind=kind, level=level, summary=summary) + + @sportsref.decorators.memoize + def stats_advanced(self, kind='R', summary=False): + """Returns a dataframe of advanced stats. + :returns: TODO (would need to pull from team page, not housed in player page) + """ + raise Exception('not yet implemented - euro.stats_advanced') + + @sportsref.decorators.memoize + @sportsref.decorators.kind_rpb(include_type=False) + def gamelog_basic(self, year, league): + """Returns a table of a player's basic game-by-game stats for a season. + + :param year: The year representing the desired season. + :param kind: specifies regular season, playoffs, or both. One of 'R', + 'P', 'B'. Defaults to 'R'. + :returns: A DataFrame of the player's standard boxscore stats from each + game of the season. + :rtype: pd.DataFrame + """ + + doc = self.get_gamelog_doc(year, league) + + table = doc('table#pgl_basic') + df = sportsref.utils.parse_table(table) + return df diff --git a/sportsref/euro/seasons.py b/sportsref/euro/seasons.py new file mode 100644 index 0000000..29188ae --- /dev/null +++ b/sportsref/euro/seasons.py @@ -0,0 +1,143 @@ +import future +import future.utils + +import pandas as pd +from pyquery import PyQuery as pq + +import sportsref + + +class Season(future.utils.with_metaclass(sportsref.decorators.Cached, object)): + + """Object representing a given Euro season.""" + + def __init__(self, year, league_id): + """Initializes a Season object for an Euro season. + + :year: The year of the season we want. + :league_id: The league_id that we want (list of league_ids can be obtained by euro.LEAGUE_IDS + """ + self.yr = int(year) + self.lg_id = league_id + + def __eq__(self, other): + return (self.yr == other.yr and self.lg_id == other.lg_id) + + def __hash__(self): + return hash(self.yr) + + def __repr__(self): + return 'Season({})'.format(self.yr) + + def _schedule_url(self): + return (sportsref.euro.BASE_URL + + '/{}/{}-schedule.htm'.format(self.lg_id, self.yr)) + + @sportsref.decorators.memoize + def get_main_doc(self): + """Returns PyQuery object for the main season URL. + :returns: PyQuery object. + """ + url = (sportsref.euro.BASE_URL + + '/{}/{}.htm'.format(self.lg_id, self.yr)) + return pq(sportsref.utils.get_html(url)) + + @sportsref.decorators.memoize + def get_schedule_doc(self): + """Returns PyQuery object for a given schedule URL. + :returns: PyQuery object. + """ + html = sportsref.utils.get_html(self._schedule_url()) + return pq(html) + + @sportsref.decorators.memoize + def get_team_ids(self): + """Returns a list of the team IDs for the given year. + :returns: List of team IDs. + """ + df = self.team_stats_per_game() + if not df.empty: + return df.index.tolist() + else: + print('ERROR: no teams found') + return [] + + @sportsref.decorators.memoize + def team_ids_to_names(self): + """Mapping from team IDs to full team names. + :returns: Dictionary with team IDs as keys and full team strings as + values. + """ + doc = self.get_main_doc() + table = doc('table#team_stats_per_game') + for a in table('a').items(): + a.removeAttr('href') + + name_table = sportsref.utils.parse_table(table) + id_table = self.team_stats_per_game() + + team_ids = id_table.index.values + team_names = name_table['team_name_season'] + if len(team_names) != len(team_ids): + raise Exception("team names and team IDs don't align") + return dict(list(zip(team_ids, team_names))) + + @sportsref.decorators.memoize + def team_names_to_ids(self): + """Mapping from full team names to team IDs. + :returns: Dictionary with tean names as keys and team IDs as values. + """ + d = self.team_ids_to_names() + return {v: k for k, v in list(d.items())} + + @sportsref.decorators.memoize + @sportsref.decorators.kind_rpb(include_type=True) + def schedule(self, kind='R'): + """Returns a list of BoxScore IDs for every game in the season. + Only needs to handle 'R' or 'P' options because decorator handles 'B'. + + :param kind: 'R' for regular season (club play), 'P' for playoffs (euroleague), 'B' for both. + Defaults to 'R'. + :returns: DataFrame of schedule information. + :rtype: pd.DataFrame + """ + doc = self.get_schedule_doc() + table_id = 'table#games' + if kind == 'P': + table_id += '_playoffs' + + table = doc(table_id) + df = sportsref.utils.parse_table(table) + return df + + + @sportsref.decorators.memoize + def _get_team_stats_table(self, selector): + """Helper function for stats tables on season pages. Returns a + DataFrame.""" + doc = self.get_main_doc() + table = doc(selector) + df = sportsref.utils.parse_table(table) + df['team_name_season'] = df['team_name_season'].apply(lambda x: x.split('/')[3]) + df.rename(columns={'team_name_season' : 'team_id'}, inplace=True) + df.set_index('team_id', inplace=True) + return df + + def standings(self): + """Returns a Pandas DataFrame of each team's basic per-game stats for + the season.""" + + if self.lg_id == 'eurocup' or self.lg_id == 'euroleague': + return self._get_team_stats_table('table#tournament_standings') + else: + return self._get_team_stats_table('table#league_standings') + + def team_stats_totals(self): + """Returns a Pandas DataFrame of each team's basic per-game stats for + the season.""" + return self._get_team_stats_table('table#team_stats_totals') + + def team_stats_per_game(self): + """Returns a Pandas DataFrame of each team's basic per-game stats for + the season.""" + return self._get_team_stats_table('table#team_stats_per_game') diff --git a/sportsref/euro/teams.py b/sportsref/euro/teams.py new file mode 100644 index 0000000..4822e31 --- /dev/null +++ b/sportsref/euro/teams.py @@ -0,0 +1,129 @@ +import future +import future.utils + +import numpy as np +from pyquery import PyQuery as pq + +import sportsref + + +class Team(future.utils.with_metaclass(sportsref.decorators.Cached, object)): + + def __init__(self, team_id): + self.team_id = team_id + + def __eq__(self, other): + return (self.team_id == other.team_id) + + def __hash__(self): + return hash(self.team_id) + + @sportsref.decorators.memoize + def team_year_url(self, year, level='B'): + yr_str = str(year) + if level == 'C': + yr_str += '_' + self.get_league_id(year=year) + elif level == 'E': + yr_str += '_euroleague' + + + return (sportsref.euro.BASE_URL + + '/teams/{}/{}.htm'.format(self.team_id, yr_str)) + + @sportsref.decorators.memoize + def schedule_url(self, year): + return (sportsref.euro.BASE_URL + '/schedules/{}/{}.htm'.format(self.team_id, year)) + + @sportsref.decorators.memoize + def get_main_doc(self): + relURL = '/teams/{}'.format(self.team_id) + teamURL = sportsref.euro.BASE_URL + relURL + mainDoc = pq(sportsref.utils.get_html(teamURL)) + return mainDoc + + @sportsref.decorators.memoize + def get_year_doc(self, yr_str, level='B'): + return pq(sportsref.utils.get_html(self.team_year_url(yr_str, level=level))) + + @sportsref.decorators.memoize + def get_schedule_doc(self, year): + return pq(sportsref.utils.get_html(self.schedule_url(year))) + + @sportsref.decorators.memoize + def get_league_id(self, year=2018): + """ Year parameter here in case team switched club-play leagues - also makes it easier to find in doc""" + doc = self.get_main_doc() + table = doc('table#team-index-club') + + start = '/euro/' + end = '/{}.html'.format(year) + + for a in table('a[href$="{}"]'.format(end)).items(): + if 'years' not in a.attr('href'): + return a.attr('href')[len(start):-len(end)] + + @sportsref.decorators.memoize + def name(self): + """Returns the real name of the franchise given the team ID. + + Example: + 'barcelona' -> 'FC Barcelona' + + :returns: A string corresponding to the team's full name. + """ + doc = self.get_main_doc() + name = doc('title').text().replace(' Seasons | Basketball-Reference.com', '') + return name + + def get_stats_table(self, table_id, year, level='B'): + doc = self.get_year_doc(year, level=level) + table = doc('table#{}'.format(table_id)) + df = sportsref.utils.parse_table(table) + + return df + + @sportsref.decorators.memoize + @sportsref.decorators.kind_rpb(include_type=True) + def schedule(self, year, kind='B'): + """Returns the teams schedule, with boxscore_ids for further investigation. + :returns: schedule Dataframe + """ + doc = self.get_schedule_doc(year) + for t in doc('table').items(): + if self.team_id in t.attr('id'): + if 'Euroleague' in t.attr('id'): + e_id = t.attr('id') + else: + c_id = t.attr('id') + if kind == 'R': + table_id = c_id + + else: + table_id = e_id + + table = doc("table[id='{}']".format(table_id)) + df = sportsref.utils.parse_table(table) + df.rename(columns={'date_game_full' : 'boxscore_id'}, inplace=True) + return df + + + @sportsref.decorators.memoize + def all_team_opp_stats(self, year, level='B'): + return self.get_stats_table('team_and_opp', year, level=level) + + @sportsref.decorators.memoize + def stats_per_game(self, year, level='B'): + return self.get_stats_table('per_game', year, level=level) + + @sportsref.decorators.memoize + def stats_totals(self, year, level='B'): + return self.get_stats_table('totals', year, level=level) + + @sportsref.decorators.memoize + def stats_per36(self, year, level='B'): + return self.get_stats_table('per_minute', year, level=level) + + @sportsref.decorators.memoize + def stats_advanced(self, year, level='B'): + return self.get_stats_table('advanced', year, level=level) + diff --git a/sportsref/nba/boxscores.py b/sportsref/nba/boxscores.py index d55495d..d5903d2 100644 --- a/sportsref/nba/boxscores.py +++ b/sportsref/nba/boxscores.py @@ -50,7 +50,7 @@ def date(self): :returns: A datetime.date object with year, month, and day attributes. """ match = re.match(r'(\d{4})(\d{2})(\d{2})', self.boxscore_id) - year, month, day = map(int, match.groups()) + year, month, day = list(map(int, match.groups())) return datetime.date(year=year, month=month, day=day) @sportsref.decorators.memoize @@ -71,8 +71,8 @@ def linescore(self): columns[0] = 'team_id' data = [ - [sportsref.utils.flatten_links(td) for td in tr('td').items()] - for tr in table('tr.thead').next_all('tr').items() + [sportsref.utils.flatten_links(td) for td in list(tr('td').items())] + for tr in list(table('tr.thead').next_all('tr').items()) ] return pd.DataFrame(data, index=['away', 'home'], @@ -194,7 +194,7 @@ def pbp(self, dense_lineups=False, sparse_lineups=False): ) table = doc('table#pbp') trs = [ - tr for tr in table('tr').items() + tr for tr in list(table('tr').items()) if (not tr.attr['class'] or # regular data rows tr.attr['id'] and tr.attr['id'].startswith('q')) # qtr bounds ] @@ -218,7 +218,7 @@ def pbp(self, dense_lineups=False, sparse_lineups=False): # add time of play to entry t_str = row.eq(0).text() t_regex = r'(\d+):(\d+)\.(\d+)' - mins, secs, tenths = map(int, re.match(t_regex, t_str).groups()) + mins, secs, tenths = list(map(int, re.match(t_regex, t_str).groups())) endQ = (12 * 60 * min(cur_qtr, 4) + 5 * 60 * (cur_qtr - 4 if cur_qtr > 4 else 0)) secsElapsed = endQ - (60 * mins + secs + 0.1 * tenths) @@ -246,11 +246,11 @@ def pbp(self, dense_lineups=False, sparse_lineups=False): # if another case, log and continue else: if not desc.text().lower().startswith('end of '): - print( + print(( '{}, Q{}, {} other case: {}' .format(self.boxscore_id, cur_qtr, t_str, desc.text()) - ) + )) continue # handle team play description @@ -276,8 +276,8 @@ def pbp(self, dense_lineups=False, sparse_lineups=False): p = orig_p new_p = new_p[1] elif new_p.get('is_error'): - print("can't parse: {}, boxscore: {}" - .format(desc, self.boxscore_id)) + print(("can't parse: {}, boxscore: {}" + .format(desc, self.boxscore_id))) # import pdb; pdb.set_trace() p.update(new_p) diff --git a/sportsref/nba/pbp.py b/sportsref/nba/pbp.py index 867a981..9c95291 100644 --- a/sportsref/nba/pbp.py +++ b/sportsref/nba/pbp.py @@ -37,7 +37,7 @@ def parse_play(boxscore_id, details, is_hm): :rtype: dictionary or None """ # if input isn't a string, return None - if not details or not isinstance(details, basestring): + if not details or not isinstance(details, str): return None bs = sportsref.nba.BoxScore(boxscore_id) @@ -498,8 +498,8 @@ def players_from_play(play): break if len(hm_starters) != 5 or len(aw_starters) != 5: - print('WARNING: wrong number of starters for a team in Q{} of {}' - .format(qtr, df.boxscore_id.iloc[0])) + print(('WARNING: wrong number of starters for a team in Q{} of {}' + .format(qtr, df.boxscore_id.iloc[0]))) return period_starters @@ -588,9 +588,9 @@ def handle_sub(row, aw_lineup, hm_lineup): ): return aw_lineup, hm_lineup # otherwise, let's print and pretend this never happened - print('ERROR IN SUB IN {}, Q{}, {}: {}' + print(('ERROR IN SUB IN {}, Q{}, {}: {}' .format(row['boxscore_id'], row['quarter'], - row['clock_time'], row['detail'])) + row['clock_time'], row['detail']))) raise return aw_lineup, hm_lineup @@ -611,7 +611,7 @@ def handle_sub(row, aw_lineup, hm_lineup): lineups[i-1] = lineup_dict(aw_lineup, hm_lineup) # then, move on to the quarter, and enter the starting lineups cur_qtr += 1 - aw_lineup, hm_lineup = map(list, per_starters[cur_qtr-1]) + aw_lineup, hm_lineup = list(map(list, per_starters[cur_qtr-1])) lineups[i] = lineup_dict(aw_lineup, hm_lineup) # if the first play in the quarter is a sub, handle that if row['is_sub']: diff --git a/sportsref/nba/players.py b/sportsref/nba/players.py index a754e02..85dc834 100644 --- a/sportsref/nba/players.py +++ b/sportsref/nba/players.py @@ -24,6 +24,7 @@ class Player(future.utils.with_metaclass(sportsref.decorators.Cached, object)): from the player's Basketball Reference player page.""" def __init__(self, player_id): + print('init called') self.player_id = player_id self.url_base = (sportsref.nba.BASE_URL + '/players/{0[0]}/{0}').format(self.player_id) @@ -43,6 +44,7 @@ def __str__(self): @sportsref.decorators.memoize def get_main_doc(self): + print('GET_MAIN_DOC called') return pq(sportsref.utils.get_html(self.main_url)) @sportsref.decorators.memoize @@ -68,7 +70,7 @@ def age(self, year, month=2, day=1): doc = self.get_main_doc() date_string = doc('span[itemprop="birthDate"]').attr('data-birth') regex = r'(\d{4})\-(\d{2})\-(\d{2})' - date_args = map(int, re.match(regex, date_string).groups()) + date_args = list(map(int, re.match(regex, date_string).groups())) birth_date = datetime.date(*date_args) age_date = datetime.date(year=year, month=month, day=day) delta = age_date - birth_date @@ -90,7 +92,7 @@ def height(self): doc = self.get_main_doc() raw = doc('span[itemprop="height"]').text() try: - feet, inches = map(int, raw.split('-')) + feet, inches = list(map(int, raw.split('-'))) return feet * 12 + inches except ValueError: return None @@ -149,9 +151,12 @@ def _get_stats_table(self, table_id, kind='R', summary=False): :returns: A DataFrame of stats. """ doc = self.get_main_doc() + #print(doc) table_id = 'table#{}{}'.format( 'playoffs_' if kind == 'P' else '', table_id) + #print(table_id) table = doc(table_id) + #print(table) df = sportsref.utils.parse_table(table, flatten=(not summary), footer=summary) return df @@ -207,6 +212,7 @@ def gamelog_basic(self, year, kind='R'): doc = self.get_sub_doc('gamelog/{}'.format(year)) table = (doc('table#pgl_basic_playoffs') if kind == 'P' else doc('table#pgl_basic')) + print('STARTED PARSING') df = sportsref.utils.parse_table(table) return df diff --git a/sportsref/nba/seasons.py b/sportsref/nba/seasons.py index 25af437..98176ef 100644 --- a/sportsref/nba/seasons.py +++ b/sportsref/nba/seasons.py @@ -84,7 +84,7 @@ def team_ids_to_names(self): team_names = unflattened['team_name'] if len(team_names) != len(team_ids): raise Exception("team names and team IDs don't align") - return dict(zip(team_ids, team_names)) + return dict(list(zip(team_ids, team_names))) @sportsref.decorators.memoize def team_names_to_ids(self): @@ -92,7 +92,7 @@ def team_names_to_ids(self): :returns: Dictionary with tean names as keys and team IDs as values. """ d = self.team_ids_to_names() - return {v: k for k, v in d.items()} + return {v: k for k, v in list(d.items())} @sportsref.decorators.memoize @sportsref.decorators.kind_rpb(include_type=True) diff --git a/sportsref/nba/teams.py b/sportsref/nba/teams.py index cadb37b..77db2f3 100644 --- a/sportsref/nba/teams.py +++ b/sportsref/nba/teams.py @@ -62,8 +62,8 @@ def roster(self, year): .replace('R', 0).replace('', np.nan).astype(float)) return df - # TODO: kind_rpb @sportsref.decorators.memoize + @sportsref.decorators.kind_rpb(include_type=True) def schedule(self, year): """Gets schedule information for a team-season. diff --git a/sportsref/nfl/boxscores.py b/sportsref/nfl/boxscores.py index 060d05b..8962599 100644 --- a/sportsref/nfl/boxscores.py +++ b/sportsref/nfl/boxscores.py @@ -54,7 +54,7 @@ def date(self): :returns: A datetime.date object with year, month, and day attributes. """ match = re.match(r'(\d{4})(\d{2})(\d{2})', self.boxscore_id) - year, month, day = map(int, match.groups()) + year, month, day = list(map(int, match.groups())) return datetime.date(year=year, month=month, day=day) @sportsref.decorators.memoize diff --git a/sportsref/nfl/players.py b/sportsref/nfl/players.py index 3921caf..d6f6338 100644 --- a/sportsref/nfl/players.py +++ b/sportsref/nfl/players.py @@ -72,7 +72,7 @@ def age(self, year, month=9, day=1): try: dateargs = re.match(r'(\d{4})\-(\d{2})\-(\d{2})', birthstring).groups() - dateargs = map(int, dateargs) + dateargs = list(map(int, dateargs)) birthDate = datetime.date(*dateargs) delta = datetime.date(year=year, month=month, day=day) - birthDate age = delta.days / 365 @@ -97,7 +97,7 @@ def height(self): doc = self.get_doc() rawText = doc('div#meta p span[itemprop="height"]').text() try: - feet, inches = map(int, rawText.split('-')) + feet, inches = list(map(int, rawText.split('-'))) return feet * 12 + inches except ValueError: return None diff --git a/sportsref/utils.py b/sportsref/utils.py index 0e7df5b..20547c5 100644 --- a/sportsref/utils.py +++ b/sportsref/utils.py @@ -74,7 +74,14 @@ def parse_table(table, flatten=True, footer=False): # get data rows = list(table('tbody tr' if not footer else 'tfoot tr') - .not_('.thead, .stat_total, .stat_average').items()) + .not_('.thead, .stat_total, .stat_average').items()) + + # edge case for team and opp euro stats (not specifying it by id in case this approach works for other tables set up like this) + if len(columns) == 0: + columns = [c.attrib['data-stat'] for c in table('.thead th[data-stat]')] + columns[0] = 'team' + rows = list(table('tr').not_('.thead').items()) + data = [ [flatten_links(td) if flatten else td.text() for td in row.items('th,td')] @@ -322,6 +329,7 @@ def rel_url_to_id(url): url.startswith(s) for s in ( '/play-index/', + '/euro/' ) ): return url diff --git a/test_notebooks/euro/euro_boxscore_test.ipynb b/test_notebooks/euro/euro_boxscore_test.ipynb new file mode 100644 index 0000000..825af71 --- /dev/null +++ b/test_notebooks/euro/euro_boxscore_test.ipynb @@ -0,0 +1,447 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# euro.BoxScore test" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from sportsref import euro" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "box = euro.BoxScore('2018-02-04-bilbao')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Non dataframe methods - not many visible changes, but differences in how to access them with pyquery in code" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2018-02-04\n", + "Sunday\n", + "bilbao\n", + "77\n", + "fuenlabrada\n", + "83\n", + "fuenlabrada\n", + "2018\n" + ] + } + ], + "source": [ + "print(box.date())\n", + "print(box.weekday())\n", + "print(box.home())\n", + "print(box.home_score())\n", + "print(box.away())\n", + "print(box.away_score())\n", + "print(box.winner())\n", + "print(box.season())\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Stats tables - very few changes" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idmpfgfgafg3fg3aftftaorbtrbaststlblktovpfptsplayer_name
0devin-thomas-130.06.09.00.00.02.06.02.04.02.04.03.00.04.014.0Thomas, Devin
1shane-hammink-128.04.05.00.00.04.04.00.03.02.01.00.00.02.012.0Hammink, Shane
2jonathan-tabu-126.02.07.01.04.07.08.00.03.00.01.00.02.04.012.0Tabu, Jonathan
3alex-mumbru-125.05.08.02.05.07.08.00.02.04.01.01.00.03.019.0Mumbrú, Álex
4axel-hervelle-119.00.02.00.00.04.04.02.04.03.00.00.01.03.04.0Hervelle, Axel
\n", + "
" + ], + "text/plain": [ + " player_id mp fg fga fg3 fg3a ft fta orb trb ast stl \\\n", + "0 devin-thomas-1 30.0 6.0 9.0 0.0 0.0 2.0 6.0 2.0 4.0 2.0 4.0 \n", + "1 shane-hammink-1 28.0 4.0 5.0 0.0 0.0 4.0 4.0 0.0 3.0 2.0 1.0 \n", + "2 jonathan-tabu-1 26.0 2.0 7.0 1.0 4.0 7.0 8.0 0.0 3.0 0.0 1.0 \n", + "3 alex-mumbru-1 25.0 5.0 8.0 2.0 5.0 7.0 8.0 0.0 2.0 4.0 1.0 \n", + "4 axel-hervelle-1 19.0 0.0 2.0 0.0 0.0 4.0 4.0 2.0 4.0 3.0 0.0 \n", + "\n", + " blk tov pf pts player_name \n", + "0 3.0 0.0 4.0 14.0 Thomas, Devin \n", + "1 0.0 0.0 2.0 12.0 Hammink, Shane \n", + "2 0.0 2.0 4.0 12.0 Tabu, Jonathan \n", + "3 1.0 0.0 3.0 19.0 Mumbrú, Álex \n", + "4 0.0 1.0 3.0 4.0 Hervelle, Axel " + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "box.get_home_stats().head()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idmpfgfgafg3fg3aftftaorbtrbaststlblktovpfptsplayer_name
0christian-eyenga-135.04.08.02.04.00.00.01.03.00.01.01.01.02.010.0Eyenga, C.
1rolands-smits-127.03.05.02.04.03.04.02.04.00.00.00.02.05.011.0Smits, Rolands
2marko-popovic-126.08.013.04.09.05.08.00.02.04.01.00.02.02.025.0Popovic, Marko
3blagota-sekulic-124.02.04.01.02.06.06.01.02.01.00.00.04.02.011.0Sekulic, Blagota
4francisco-cruz-124.04.08.01.04.01.02.00.02.04.02.00.01.01.010.0Cruz, Francisco
\n", + "
" + ], + "text/plain": [ + " player_id mp fg fga fg3 fg3a ft fta orb trb ast \\\n", + "0 christian-eyenga-1 35.0 4.0 8.0 2.0 4.0 0.0 0.0 1.0 3.0 0.0 \n", + "1 rolands-smits-1 27.0 3.0 5.0 2.0 4.0 3.0 4.0 2.0 4.0 0.0 \n", + "2 marko-popovic-1 26.0 8.0 13.0 4.0 9.0 5.0 8.0 0.0 2.0 4.0 \n", + "3 blagota-sekulic-1 24.0 2.0 4.0 1.0 2.0 6.0 6.0 1.0 2.0 1.0 \n", + "4 francisco-cruz-1 24.0 4.0 8.0 1.0 4.0 1.0 2.0 0.0 2.0 4.0 \n", + "\n", + " stl blk tov pf pts player_name \n", + "0 1.0 1.0 1.0 2.0 10.0 Eyenga, C. \n", + "1 0.0 0.0 2.0 5.0 11.0 Smits, Rolands \n", + "2 1.0 0.0 2.0 2.0 25.0 Popovic, Marko \n", + "3 0.0 0.0 4.0 2.0 11.0 Sekulic, Blagota \n", + "4 2.0 0.0 1.0 1.0 10.0 Cruz, Francisco " + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "box.get_away_stats().head()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/test_notebooks/euro/euro_player_test.ipynb b/test_notebooks/euro/euro_player_test.ipynb new file mode 100644 index 0000000..bee655c --- /dev/null +++ b/test_notebooks/euro/euro_player_test.ipynb @@ -0,0 +1,3740 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# euro.Player test" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "from sportsref import euro" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "player = euro.Player('victor-claver-1')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## simple methods: Almost no changes" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Victor Claver\n", + "28.443835616438356\n", + "81\n", + "224\n" + ] + } + ], + "source": [ + "print(player.name())\n", + "print(player.age(2017))\n", + "print(player.height())\n", + "print(player.weight())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Added position and nba_id\n", + "### If player also played in NBA, returns their bballref id, if not, returns None" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SForward\n", + "clavevi01\n" + ] + } + ], + "source": [ + "print(player.position())\n", + "print(player.nba_id())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Gamelogs - different url style" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[(2016, 'ELG'), (2017, 'ELG'), (2017, 'SPA'), (2018, 'ELG'), (2018, 'SPA')]\n" + ] + } + ], + "source": [ + "# new method: to me, would be useful/necessary\n", + "# because gamelogs are split by league and year\n", + "\n", + "print(player.available_gamelogs())" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
boxscore_idageteam_idis_homeopp_idgame_resultmpfgfgafg_pct...orbdrbtrbaststlblktovpfptsgame_score
02016-10-02-manresa28-033BarcelonaFalseManresaW17.8500000.04.00.000...0.03.03.00.02.02.03.01.00.0-1.9
12016-10-09-barcelona28-040BarcelonaTrueVitoriaW24.4833331.04.00.250...1.05.06.02.00.01.02.01.02.01.5
22016-10-16-bilbao28-047BarcelonaFalseBilbaoL18.4666670.02.00.000...0.00.00.02.00.00.02.05.01.0-3.4
32016-10-23-barcelona28-054BarcelonaTrueSevillaW19.3166671.03.00.333...0.02.02.02.01.00.02.01.02.00.9
42016-10-30-fuenlabrada28-061BarcelonaFalseFuenlabradaW10.2500000.02.00.000...0.01.01.00.01.00.01.02.00.0-1.9
\n", + "

5 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " boxscore_id age team_id is_home opp_id \\\n", + "0 2016-10-02-manresa 28-033 Barcelona False Manresa \n", + "1 2016-10-09-barcelona 28-040 Barcelona True Vitoria \n", + "2 2016-10-16-bilbao 28-047 Barcelona False Bilbao \n", + "3 2016-10-23-barcelona 28-054 Barcelona True Sevilla \n", + "4 2016-10-30-fuenlabrada 28-061 Barcelona False Fuenlabrada \n", + "\n", + " game_result mp fg fga fg_pct ... orb drb trb ast \\\n", + "0 W 17.850000 0.0 4.0 0.000 ... 0.0 3.0 3.0 0.0 \n", + "1 W 24.483333 1.0 4.0 0.250 ... 1.0 5.0 6.0 2.0 \n", + "2 L 18.466667 0.0 2.0 0.000 ... 0.0 0.0 0.0 2.0 \n", + "3 W 19.316667 1.0 3.0 0.333 ... 0.0 2.0 2.0 2.0 \n", + "4 W 10.250000 0.0 2.0 0.000 ... 0.0 1.0 1.0 0.0 \n", + "\n", + " stl blk tov pf pts game_score \n", + "0 2.0 2.0 3.0 1.0 0.0 -1.9 \n", + "1 0.0 1.0 2.0 1.0 2.0 1.5 \n", + "2 0.0 0.0 2.0 5.0 1.0 -3.4 \n", + "3 1.0 0.0 2.0 1.0 2.0 0.9 \n", + "4 1.0 0.0 1.0 2.0 0.0 -1.9 \n", + "\n", + "[5 rows x 26 columns]" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "player.gamelog_basic(2017, 'SPA').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
boxscore_idageteam_idis_homeopp_idgame_resultmpfgfgafg_pct...orbdrbtrbaststlblktovpfptsgame_score
02017-11-03-barcelona29-065BarcelonaTrueOlympiakosW11.5000000.02.00.000...0.02.02.01.02.01.00.03.00.01.4
12017-11-09-barcelona29-071BarcelonaTrueAnadolu-EfesL15.2166675.07.00.714...2.00.02.01.03.00.00.01.012.013.8
22017-11-15-brose-baskets29-077BarcelonaFalseBrose-BasketsL15.8166671.03.00.333...0.04.04.01.00.00.02.01.03.00.8
32017-11-23-barcelona29-085BarcelonaTrueMaccabi-Tel-AvivW17.3333331.03.00.333...1.02.03.02.00.00.00.04.03.02.4
42017-12-01-cska-moscow29-093BarcelonaFalseCska-MoscowL6.5833330.00.0NaN...0.01.01.00.00.00.01.01.00.0-1.1
\n", + "

5 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " boxscore_id age team_id is_home opp_id \\\n", + "0 2017-11-03-barcelona 29-065 Barcelona True Olympiakos \n", + "1 2017-11-09-barcelona 29-071 Barcelona True Anadolu-Efes \n", + "2 2017-11-15-brose-baskets 29-077 Barcelona False Brose-Baskets \n", + "3 2017-11-23-barcelona 29-085 Barcelona True Maccabi-Tel-Aviv \n", + "4 2017-12-01-cska-moscow 29-093 Barcelona False Cska-Moscow \n", + "\n", + " game_result mp fg fga fg_pct ... orb drb trb ast \\\n", + "0 W 11.500000 0.0 2.0 0.000 ... 0.0 2.0 2.0 1.0 \n", + "1 L 15.216667 5.0 7.0 0.714 ... 2.0 0.0 2.0 1.0 \n", + "2 L 15.816667 1.0 3.0 0.333 ... 0.0 4.0 4.0 1.0 \n", + "3 W 17.333333 1.0 3.0 0.333 ... 1.0 2.0 3.0 2.0 \n", + "4 L 6.583333 0.0 0.0 NaN ... 0.0 1.0 1.0 0.0 \n", + "\n", + " stl blk tov pf pts game_score \n", + "0 2.0 1.0 0.0 3.0 0.0 1.4 \n", + "1 3.0 0.0 0.0 1.0 12.0 13.8 \n", + "2 0.0 0.0 2.0 1.0 3.0 0.8 \n", + "3 0.0 0.0 0.0 4.0 3.0 2.4 \n", + "4 0.0 0.0 1.0 1.0 0.0 -1.1 \n", + "\n", + "[5 rows x 26 columns]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "player.gamelog_basic(2018, 'ELG').head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## stat_tables:\n", + "\n", + "\n", + "### took out stats_per100, stats_advanced, stats_shooting, stats_pbp (data not on bballref)\n", + "\n", + "### changed table_ids\n", + "\n", + "### parameters:\n", + "\n", + "### Kind (works the same)\n", + "\n", + "### Level (needed, because different docs are pulled from)\n", + "\n", + "#### -B (pulls from main milos-teodosic doc - default)\n", + "#### -C (pulls from milos-teodosic-club)\n", + "#### -E (pulls from milos-teodosic-tournament, which is Eurocup/Euroleague play)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Test: level='B' - Both" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='R', level='B')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_gfg3a_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007Liga ACB19.0NaN6.60.92.20.4050.20.7...0.40.60.90.40.40.20.60.52.3False
12008ULEB Cup, Liga ACB48.0NaN17.72.24.60.4800.72.0...0.82.22.90.90.70.41.31.85.9False
22009Liga ACB, EuroCup20.0NaN21.32.54.80.5210.92.2...0.73.44.10.80.90.61.22.07.1False
32010Liga ACB, EuroCup50.0NaN25.63.06.80.4420.92.9...1.03.94.91.61.00.41.82.38.2False
42011EuroLeague, Liga ACB38.0NaN28.43.88.20.4651.33.3...1.13.64.71.81.40.62.22.211.3False
\n", + "

5 rows × 27 columns

\n", + "
" + ], + "text/plain": [ + " season lg_name g gs mp_per_g fg_per_g fga_per_g \\\n", + "0 2007 Liga ACB 19.0 NaN 6.6 0.9 2.2 \n", + "1 2008 ULEB Cup, Liga ACB 48.0 NaN 17.7 2.2 4.6 \n", + "2 2009 Liga ACB, EuroCup 20.0 NaN 21.3 2.5 4.8 \n", + "3 2010 Liga ACB, EuroCup 50.0 NaN 25.6 3.0 6.8 \n", + "4 2011 EuroLeague, Liga ACB 38.0 NaN 28.4 3.8 8.2 \n", + "\n", + " fg_pct fg3_per_g fg3a_per_g ... orb_per_g drb_per_g \\\n", + "0 0.405 0.2 0.7 ... 0.4 0.6 \n", + "1 0.480 0.7 2.0 ... 0.8 2.2 \n", + "2 0.521 0.9 2.2 ... 0.7 3.4 \n", + "3 0.442 0.9 2.9 ... 1.0 3.9 \n", + "4 0.465 1.3 3.3 ... 1.1 3.6 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 0.9 0.4 0.4 0.2 0.6 0.5 2.3 \n", + "1 2.9 0.9 0.7 0.4 1.3 1.8 5.9 \n", + "2 4.1 0.8 0.9 0.6 1.2 2.0 7.1 \n", + "3 4.9 1.6 1.0 0.4 1.8 2.3 8.2 \n", + "4 4.7 1.8 1.4 0.6 2.2 2.2 11.3 \n", + "\n", + " is_playoffs \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + "\n", + "[5 rows x 27 columns]" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='P', level='B')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_gfg3a_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007Liga ACB4.0NaN20.84.08.00.5001.03.3...0.81.32.00.80.30.81.00.811.5True
12008Liga ACB3.0NaN12.30.72.00.3330.00.7...0.71.72.30.70.30.00.71.02.7True
22009Liga ACB2.0NaN25.00.55.00.1000.02.0...1.03.54.50.51.50.02.02.02.5True
32010Liga ACB2.0NaN23.53.07.00.4291.03.0...0.52.02.51.00.50.51.51.58.0True
42011Liga ACB2.0NaN27.02.06.50.3080.52.5...0.52.53.01.01.00.03.03.56.0True
\n", + "

5 rows × 27 columns

\n", + "
" + ], + "text/plain": [ + " season lg_name g gs mp_per_g fg_per_g fga_per_g fg_pct \\\n", + "0 2007 Liga ACB 4.0 NaN 20.8 4.0 8.0 0.500 \n", + "1 2008 Liga ACB 3.0 NaN 12.3 0.7 2.0 0.333 \n", + "2 2009 Liga ACB 2.0 NaN 25.0 0.5 5.0 0.100 \n", + "3 2010 Liga ACB 2.0 NaN 23.5 3.0 7.0 0.429 \n", + "4 2011 Liga ACB 2.0 NaN 27.0 2.0 6.5 0.308 \n", + "\n", + " fg3_per_g fg3a_per_g ... orb_per_g drb_per_g trb_per_g \\\n", + "0 1.0 3.3 ... 0.8 1.3 2.0 \n", + "1 0.0 0.7 ... 0.7 1.7 2.3 \n", + "2 0.0 2.0 ... 1.0 3.5 4.5 \n", + "3 1.0 3.0 ... 0.5 2.0 2.5 \n", + "4 0.5 2.5 ... 0.5 2.5 3.0 \n", + "\n", + " ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 0.8 0.3 0.8 1.0 0.8 11.5 \n", + "1 0.7 0.3 0.0 0.7 1.0 2.7 \n", + "2 0.5 1.5 0.0 2.0 2.0 2.5 \n", + "3 1.0 0.5 0.5 1.5 1.5 8.0 \n", + "4 1.0 1.0 0.0 3.0 3.5 6.0 \n", + "\n", + " is_playoffs \n", + "0 True \n", + "1 True \n", + "2 True \n", + "3 True \n", + "4 True \n", + "\n", + "[5 rows x 27 columns]" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='B', level='B')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_gfg3a_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007Liga ACB19.0NaN6.60.92.20.4050.20.7...0.40.60.90.40.40.20.60.52.3False
12008ULEB Cup, Liga ACB48.0NaN17.72.24.60.4800.72.0...0.82.22.90.90.70.41.31.85.9False
22009Liga ACB, EuroCup20.0NaN21.32.54.80.5210.92.2...0.73.44.10.80.90.61.22.07.1False
32010Liga ACB, EuroCup50.0NaN25.63.06.80.4420.92.9...1.03.94.91.61.00.41.82.38.2False
42011EuroLeague, Liga ACB38.0NaN28.43.88.20.4651.33.3...1.13.64.71.81.40.62.22.211.3False
52012EuroCup, Liga ACB37.0NaN25.83.07.20.4151.23.4...1.22.43.61.31.20.41.92.68.7False
62016EuroLeague31.0NaN27.03.57.00.5001.12.7...1.74.15.91.60.80.51.01.79.4False
72017EuroLeague, Liga ACB56.0NaN21.22.04.30.4710.92.2...0.83.44.31.20.90.41.32.05.5False
82018EuroLeague, Liga ACB29.0NaN14.91.53.40.4400.51.6...0.51.62.11.00.70.30.41.94.0False
92007Liga ACB4.0NaN20.84.08.00.5001.03.3...0.81.32.00.80.30.81.00.811.5True
102008Liga ACB3.0NaN12.30.72.00.3330.00.7...0.71.72.30.70.30.00.71.02.7True
112009Liga ACB2.0NaN25.00.55.00.1000.02.0...1.03.54.50.51.50.02.02.02.5True
122010Liga ACB2.0NaN23.53.07.00.4291.03.0...0.52.02.51.00.50.51.51.58.0True
132011Liga ACB2.0NaN27.02.06.50.3080.52.5...0.52.53.01.01.00.03.03.56.0True
142012Liga ACB7.0NaN27.72.05.90.3410.42.1...1.03.34.30.91.00.42.32.95.1True
152017Liga ACB3.0NaN23.72.35.30.4381.02.3...1.03.34.31.01.70.32.31.36.7True
\n", + "

16 rows × 27 columns

\n", + "
" + ], + "text/plain": [ + " season lg_name g gs mp_per_g fg_per_g fga_per_g \\\n", + "0 2007 Liga ACB 19.0 NaN 6.6 0.9 2.2 \n", + "1 2008 ULEB Cup, Liga ACB 48.0 NaN 17.7 2.2 4.6 \n", + "2 2009 Liga ACB, EuroCup 20.0 NaN 21.3 2.5 4.8 \n", + "3 2010 Liga ACB, EuroCup 50.0 NaN 25.6 3.0 6.8 \n", + "4 2011 EuroLeague, Liga ACB 38.0 NaN 28.4 3.8 8.2 \n", + "5 2012 EuroCup, Liga ACB 37.0 NaN 25.8 3.0 7.2 \n", + "6 2016 EuroLeague 31.0 NaN 27.0 3.5 7.0 \n", + "7 2017 EuroLeague, Liga ACB 56.0 NaN 21.2 2.0 4.3 \n", + "8 2018 EuroLeague, Liga ACB 29.0 NaN 14.9 1.5 3.4 \n", + "9 2007 Liga ACB 4.0 NaN 20.8 4.0 8.0 \n", + "10 2008 Liga ACB 3.0 NaN 12.3 0.7 2.0 \n", + "11 2009 Liga ACB 2.0 NaN 25.0 0.5 5.0 \n", + "12 2010 Liga ACB 2.0 NaN 23.5 3.0 7.0 \n", + "13 2011 Liga ACB 2.0 NaN 27.0 2.0 6.5 \n", + "14 2012 Liga ACB 7.0 NaN 27.7 2.0 5.9 \n", + "15 2017 Liga ACB 3.0 NaN 23.7 2.3 5.3 \n", + "\n", + " fg_pct fg3_per_g fg3a_per_g ... orb_per_g drb_per_g \\\n", + "0 0.405 0.2 0.7 ... 0.4 0.6 \n", + "1 0.480 0.7 2.0 ... 0.8 2.2 \n", + "2 0.521 0.9 2.2 ... 0.7 3.4 \n", + "3 0.442 0.9 2.9 ... 1.0 3.9 \n", + "4 0.465 1.3 3.3 ... 1.1 3.6 \n", + "5 0.415 1.2 3.4 ... 1.2 2.4 \n", + "6 0.500 1.1 2.7 ... 1.7 4.1 \n", + "7 0.471 0.9 2.2 ... 0.8 3.4 \n", + "8 0.440 0.5 1.6 ... 0.5 1.6 \n", + "9 0.500 1.0 3.3 ... 0.8 1.3 \n", + "10 0.333 0.0 0.7 ... 0.7 1.7 \n", + "11 0.100 0.0 2.0 ... 1.0 3.5 \n", + "12 0.429 1.0 3.0 ... 0.5 2.0 \n", + "13 0.308 0.5 2.5 ... 0.5 2.5 \n", + "14 0.341 0.4 2.1 ... 1.0 3.3 \n", + "15 0.438 1.0 2.3 ... 1.0 3.3 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g \\\n", + "0 0.9 0.4 0.4 0.2 0.6 0.5 \n", + "1 2.9 0.9 0.7 0.4 1.3 1.8 \n", + "2 4.1 0.8 0.9 0.6 1.2 2.0 \n", + "3 4.9 1.6 1.0 0.4 1.8 2.3 \n", + "4 4.7 1.8 1.4 0.6 2.2 2.2 \n", + "5 3.6 1.3 1.2 0.4 1.9 2.6 \n", + "6 5.9 1.6 0.8 0.5 1.0 1.7 \n", + "7 4.3 1.2 0.9 0.4 1.3 2.0 \n", + "8 2.1 1.0 0.7 0.3 0.4 1.9 \n", + "9 2.0 0.8 0.3 0.8 1.0 0.8 \n", + "10 2.3 0.7 0.3 0.0 0.7 1.0 \n", + "11 4.5 0.5 1.5 0.0 2.0 2.0 \n", + "12 2.5 1.0 0.5 0.5 1.5 1.5 \n", + "13 3.0 1.0 1.0 0.0 3.0 3.5 \n", + "14 4.3 0.9 1.0 0.4 2.3 2.9 \n", + "15 4.3 1.0 1.7 0.3 2.3 1.3 \n", + "\n", + " pts_per_g is_playoffs \n", + "0 2.3 False \n", + "1 5.9 False \n", + "2 7.1 False \n", + "3 8.2 False \n", + "4 11.3 False \n", + "5 8.7 False \n", + "6 9.4 False \n", + "7 5.5 False \n", + "8 4.0 False \n", + "9 11.5 True \n", + "10 2.7 True \n", + "11 2.5 True \n", + "12 8.0 True \n", + "13 6.0 True \n", + "14 5.1 True \n", + "15 6.7 True \n", + "\n", + "[16 rows x 27 columns]" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head(20)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Test: level='C' - Club" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='R', level='C')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_namelg_countryggsmp_per_gfg_per_gfga_per_gfg_pct...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007/euro/teams/valencia/2007.htmlLiga ACBes19.0NaN6.60.92.20.405...0.40.60.90.40.40.20.60.52.3False
12008/euro/teams/valencia/2008.htmlLiga ACBes34.0NaN18.12.44.90.491...0.92.23.11.00.60.31.32.06.5False
22009/euro/teams/valencia/2009.htmlLiga ACBes16.0NaN22.62.85.30.529...0.93.64.50.61.10.51.32.18.3False
32010/euro/teams/valencia/2010.htmlLiga ACBes34.0NaN25.43.06.70.450...1.03.94.81.50.90.41.82.28.2False
42011/euro/teams/valencia/2011.htmlLiga ACBes24.0NaN28.83.98.50.461...1.13.54.62.11.40.72.02.011.5False
\n", + "

5 rows × 29 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name lg_country g gs \\\n", + "0 2007 /euro/teams/valencia/2007.html Liga ACB es 19.0 NaN \n", + "1 2008 /euro/teams/valencia/2008.html Liga ACB es 34.0 NaN \n", + "2 2009 /euro/teams/valencia/2009.html Liga ACB es 16.0 NaN \n", + "3 2010 /euro/teams/valencia/2010.html Liga ACB es 34.0 NaN \n", + "4 2011 /euro/teams/valencia/2011.html Liga ACB es 24.0 NaN \n", + "\n", + " mp_per_g fg_per_g fga_per_g fg_pct ... orb_per_g drb_per_g \\\n", + "0 6.6 0.9 2.2 0.405 ... 0.4 0.6 \n", + "1 18.1 2.4 4.9 0.491 ... 0.9 2.2 \n", + "2 22.6 2.8 5.3 0.529 ... 0.9 3.6 \n", + "3 25.4 3.0 6.7 0.450 ... 1.0 3.9 \n", + "4 28.8 3.9 8.5 0.461 ... 1.1 3.5 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 0.9 0.4 0.4 0.2 0.6 0.5 2.3 \n", + "1 3.1 1.0 0.6 0.3 1.3 2.0 6.5 \n", + "2 4.5 0.6 1.1 0.5 1.3 2.1 8.3 \n", + "3 4.8 1.5 0.9 0.4 1.8 2.2 8.2 \n", + "4 4.6 2.1 1.4 0.7 2.0 2.0 11.5 \n", + "\n", + " is_playoffs \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + "\n", + "[5 rows x 29 columns]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='P', level='C')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_namelg_countryggsmp_per_gfg_per_gfga_per_gfg_pct...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007/euro/teams/valencia/2007.htmlLiga ACBes4.0NaN20.84.08.00.500...0.81.32.00.80.30.81.00.811.5True
12008/euro/teams/valencia/2008.htmlLiga ACBes3.0NaN12.30.72.00.333...0.71.72.30.70.30.00.71.02.7True
22009/euro/teams/valencia/2009.htmlLiga ACBes2.0NaN25.00.55.00.100...1.03.54.50.51.50.02.02.02.5True
32010/euro/teams/valencia/2010.htmlLiga ACBes2.0NaN23.53.07.00.429...0.52.02.51.00.50.51.51.58.0True
42011/euro/teams/valencia/2011.htmlLiga ACBes2.0NaN27.02.06.50.308...0.52.53.01.01.00.03.03.56.0True
\n", + "

5 rows × 29 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name lg_country g gs \\\n", + "0 2007 /euro/teams/valencia/2007.html Liga ACB es 4.0 NaN \n", + "1 2008 /euro/teams/valencia/2008.html Liga ACB es 3.0 NaN \n", + "2 2009 /euro/teams/valencia/2009.html Liga ACB es 2.0 NaN \n", + "3 2010 /euro/teams/valencia/2010.html Liga ACB es 2.0 NaN \n", + "4 2011 /euro/teams/valencia/2011.html Liga ACB es 2.0 NaN \n", + "\n", + " mp_per_g fg_per_g fga_per_g fg_pct ... orb_per_g drb_per_g \\\n", + "0 20.8 4.0 8.0 0.500 ... 0.8 1.3 \n", + "1 12.3 0.7 2.0 0.333 ... 0.7 1.7 \n", + "2 25.0 0.5 5.0 0.100 ... 1.0 3.5 \n", + "3 23.5 3.0 7.0 0.429 ... 0.5 2.0 \n", + "4 27.0 2.0 6.5 0.308 ... 0.5 2.5 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 2.0 0.8 0.3 0.8 1.0 0.8 11.5 \n", + "1 2.3 0.7 0.3 0.0 0.7 1.0 2.7 \n", + "2 4.5 0.5 1.5 0.0 2.0 2.0 2.5 \n", + "3 2.5 1.0 0.5 0.5 1.5 1.5 8.0 \n", + "4 3.0 1.0 1.0 0.0 3.0 3.5 6.0 \n", + "\n", + " is_playoffs \n", + "0 True \n", + "1 True \n", + "2 True \n", + "3 True \n", + "4 True \n", + "\n", + "[5 rows x 29 columns]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "15\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='B', level='C')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_namelg_countryggsmp_per_gfg_per_gfga_per_gfg_pct...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02007/euro/teams/valencia/2007.htmlLiga ACBes19.0NaN6.60.92.20.405...0.40.60.90.40.40.20.60.52.3False
12008/euro/teams/valencia/2008.htmlLiga ACBes34.0NaN18.12.44.90.491...0.92.23.11.00.60.31.32.06.5False
22009/euro/teams/valencia/2009.htmlLiga ACBes16.0NaN22.62.85.30.529...0.93.64.50.61.10.51.32.18.3False
32010/euro/teams/valencia/2010.htmlLiga ACBes34.0NaN25.43.06.70.450...1.03.94.81.50.90.41.82.28.2False
42011/euro/teams/valencia/2011.htmlLiga ACBes24.0NaN28.83.98.50.461...1.13.54.62.11.40.72.02.011.5False
52012/euro/teams/valencia/2012.htmlLiga ACBes27.0NaN25.32.97.00.420...1.22.33.51.31.10.52.02.58.4False
62017/euro/teams/barcelona/2017.htmlLiga ACBes29.0NaN20.41.94.00.483...0.83.34.11.20.90.61.42.35.0False
72018/euro/teams/barcelona/2018.htmlLiga ACBes12.0NaN16.61.43.30.425...0.41.72.11.00.80.30.52.23.8False
82007/euro/teams/valencia/2007.htmlLiga ACBes4.0NaN20.84.08.00.500...0.81.32.00.80.30.81.00.811.5True
92008/euro/teams/valencia/2008.htmlLiga ACBes3.0NaN12.30.72.00.333...0.71.72.30.70.30.00.71.02.7True
102009/euro/teams/valencia/2009.htmlLiga ACBes2.0NaN25.00.55.00.100...1.03.54.50.51.50.02.02.02.5True
112010/euro/teams/valencia/2010.htmlLiga ACBes2.0NaN23.53.07.00.429...0.52.02.51.00.50.51.51.58.0True
122011/euro/teams/valencia/2011.htmlLiga ACBes2.0NaN27.02.06.50.308...0.52.53.01.01.00.03.03.56.0True
132012/euro/teams/valencia/2012.htmlLiga ACBes7.0NaN27.72.05.90.341...1.03.34.30.91.00.42.32.95.1True
142017/euro/teams/barcelona/2017.htmlLiga ACBes3.0NaN23.72.35.30.438...1.03.34.31.01.70.32.31.36.7True
\n", + "

15 rows × 29 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name lg_country g gs \\\n", + "0 2007 /euro/teams/valencia/2007.html Liga ACB es 19.0 NaN \n", + "1 2008 /euro/teams/valencia/2008.html Liga ACB es 34.0 NaN \n", + "2 2009 /euro/teams/valencia/2009.html Liga ACB es 16.0 NaN \n", + "3 2010 /euro/teams/valencia/2010.html Liga ACB es 34.0 NaN \n", + "4 2011 /euro/teams/valencia/2011.html Liga ACB es 24.0 NaN \n", + "5 2012 /euro/teams/valencia/2012.html Liga ACB es 27.0 NaN \n", + "6 2017 /euro/teams/barcelona/2017.html Liga ACB es 29.0 NaN \n", + "7 2018 /euro/teams/barcelona/2018.html Liga ACB es 12.0 NaN \n", + "8 2007 /euro/teams/valencia/2007.html Liga ACB es 4.0 NaN \n", + "9 2008 /euro/teams/valencia/2008.html Liga ACB es 3.0 NaN \n", + "10 2009 /euro/teams/valencia/2009.html Liga ACB es 2.0 NaN \n", + "11 2010 /euro/teams/valencia/2010.html Liga ACB es 2.0 NaN \n", + "12 2011 /euro/teams/valencia/2011.html Liga ACB es 2.0 NaN \n", + "13 2012 /euro/teams/valencia/2012.html Liga ACB es 7.0 NaN \n", + "14 2017 /euro/teams/barcelona/2017.html Liga ACB es 3.0 NaN \n", + "\n", + " mp_per_g fg_per_g fga_per_g fg_pct ... orb_per_g drb_per_g \\\n", + "0 6.6 0.9 2.2 0.405 ... 0.4 0.6 \n", + "1 18.1 2.4 4.9 0.491 ... 0.9 2.2 \n", + "2 22.6 2.8 5.3 0.529 ... 0.9 3.6 \n", + "3 25.4 3.0 6.7 0.450 ... 1.0 3.9 \n", + "4 28.8 3.9 8.5 0.461 ... 1.1 3.5 \n", + "5 25.3 2.9 7.0 0.420 ... 1.2 2.3 \n", + "6 20.4 1.9 4.0 0.483 ... 0.8 3.3 \n", + "7 16.6 1.4 3.3 0.425 ... 0.4 1.7 \n", + "8 20.8 4.0 8.0 0.500 ... 0.8 1.3 \n", + "9 12.3 0.7 2.0 0.333 ... 0.7 1.7 \n", + "10 25.0 0.5 5.0 0.100 ... 1.0 3.5 \n", + "11 23.5 3.0 7.0 0.429 ... 0.5 2.0 \n", + "12 27.0 2.0 6.5 0.308 ... 0.5 2.5 \n", + "13 27.7 2.0 5.9 0.341 ... 1.0 3.3 \n", + "14 23.7 2.3 5.3 0.438 ... 1.0 3.3 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g \\\n", + "0 0.9 0.4 0.4 0.2 0.6 0.5 \n", + "1 3.1 1.0 0.6 0.3 1.3 2.0 \n", + "2 4.5 0.6 1.1 0.5 1.3 2.1 \n", + "3 4.8 1.5 0.9 0.4 1.8 2.2 \n", + "4 4.6 2.1 1.4 0.7 2.0 2.0 \n", + "5 3.5 1.3 1.1 0.5 2.0 2.5 \n", + "6 4.1 1.2 0.9 0.6 1.4 2.3 \n", + "7 2.1 1.0 0.8 0.3 0.5 2.2 \n", + "8 2.0 0.8 0.3 0.8 1.0 0.8 \n", + "9 2.3 0.7 0.3 0.0 0.7 1.0 \n", + "10 4.5 0.5 1.5 0.0 2.0 2.0 \n", + "11 2.5 1.0 0.5 0.5 1.5 1.5 \n", + "12 3.0 1.0 1.0 0.0 3.0 3.5 \n", + "13 4.3 0.9 1.0 0.4 2.3 2.9 \n", + "14 4.3 1.0 1.7 0.3 2.3 1.3 \n", + "\n", + " pts_per_g is_playoffs \n", + "0 2.3 False \n", + "1 6.5 False \n", + "2 8.3 False \n", + "3 8.2 False \n", + "4 11.5 False \n", + "5 8.4 False \n", + "6 5.0 False \n", + "7 3.8 False \n", + "8 11.5 True \n", + "9 2.7 True \n", + "10 2.5 True \n", + "11 8.0 True \n", + "12 6.0 True \n", + "13 5.1 True \n", + "14 6.7 True \n", + "\n", + "[15 rows x 29 columns]" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head(20)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Test: level='E' - Eurocup/Euroleague (because Eurocup/Euroleague will never have sep playoffs, kind modifier does nothing) -> need to deal with duplicate when kind='B' " + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='B', level='E')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02008/euro/teams/valencia/2008.htmlULEB Cup14.0NaN16.61.84.00.4460.6...0.42.12.50.60.90.61.31.44.4False
12009/euro/teams/valencia/2009.htmlEuroCup4.0NaN15.81.32.80.4550.0...0.02.52.51.50.00.81.01.32.5False
22010/euro/teams/valencia/2010.htmlEuroCup16.0NaN26.12.96.90.4271.0...1.23.95.11.71.10.41.72.48.3False
32011/euro/teams/valencia/2011.htmlEuroLeague14.0NaN27.63.67.70.4721.0...0.93.94.91.41.40.42.52.510.9False
42012/euro/teams/valencia/2012.htmlEuroCup10.0NaN27.33.17.70.4031.2...1.22.53.71.31.50.21.83.09.4False
\n", + "

5 rows × 28 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name g gs mp_per_g \\\n", + "0 2008 /euro/teams/valencia/2008.html ULEB Cup 14.0 NaN 16.6 \n", + "1 2009 /euro/teams/valencia/2009.html EuroCup 4.0 NaN 15.8 \n", + "2 2010 /euro/teams/valencia/2010.html EuroCup 16.0 NaN 26.1 \n", + "3 2011 /euro/teams/valencia/2011.html EuroLeague 14.0 NaN 27.6 \n", + "4 2012 /euro/teams/valencia/2012.html EuroCup 10.0 NaN 27.3 \n", + "\n", + " fg_per_g fga_per_g fg_pct fg3_per_g ... orb_per_g drb_per_g \\\n", + "0 1.8 4.0 0.446 0.6 ... 0.4 2.1 \n", + "1 1.3 2.8 0.455 0.0 ... 0.0 2.5 \n", + "2 2.9 6.9 0.427 1.0 ... 1.2 3.9 \n", + "3 3.6 7.7 0.472 1.0 ... 0.9 3.9 \n", + "4 3.1 7.7 0.403 1.2 ... 1.2 2.5 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 2.5 0.6 0.9 0.6 1.3 1.4 4.4 \n", + "1 2.5 1.5 0.0 0.8 1.0 1.3 2.5 \n", + "2 5.1 1.7 1.1 0.4 1.7 2.4 8.3 \n", + "3 4.9 1.4 1.4 0.4 2.5 2.5 10.9 \n", + "4 3.7 1.3 1.5 0.2 1.8 3.0 9.4 \n", + "\n", + " is_playoffs \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + "\n", + "[5 rows x 28 columns]" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='R', level='E')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02008/euro/teams/valencia/2008.htmlULEB Cup14.0NaN16.61.84.00.4460.6...0.42.12.50.60.90.61.31.44.4False
12009/euro/teams/valencia/2009.htmlEuroCup4.0NaN15.81.32.80.4550.0...0.02.52.51.50.00.81.01.32.5False
22010/euro/teams/valencia/2010.htmlEuroCup16.0NaN26.12.96.90.4271.0...1.23.95.11.71.10.41.72.48.3False
32011/euro/teams/valencia/2011.htmlEuroLeague14.0NaN27.63.67.70.4721.0...0.93.94.91.41.40.42.52.510.9False
42012/euro/teams/valencia/2012.htmlEuroCup10.0NaN27.33.17.70.4031.2...1.22.53.71.31.50.21.83.09.4False
\n", + "

5 rows × 28 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name g gs mp_per_g \\\n", + "0 2008 /euro/teams/valencia/2008.html ULEB Cup 14.0 NaN 16.6 \n", + "1 2009 /euro/teams/valencia/2009.html EuroCup 4.0 NaN 15.8 \n", + "2 2010 /euro/teams/valencia/2010.html EuroCup 16.0 NaN 26.1 \n", + "3 2011 /euro/teams/valencia/2011.html EuroLeague 14.0 NaN 27.6 \n", + "4 2012 /euro/teams/valencia/2012.html EuroCup 10.0 NaN 27.3 \n", + "\n", + " fg_per_g fga_per_g fg_pct fg3_per_g ... orb_per_g drb_per_g \\\n", + "0 1.8 4.0 0.446 0.6 ... 0.4 2.1 \n", + "1 1.3 2.8 0.455 0.0 ... 0.0 2.5 \n", + "2 2.9 6.9 0.427 1.0 ... 1.2 3.9 \n", + "3 3.6 7.7 0.472 1.0 ... 0.9 3.9 \n", + "4 3.1 7.7 0.403 1.2 ... 1.2 2.5 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 2.5 0.6 0.9 0.6 1.3 1.4 4.4 \n", + "1 2.5 1.5 0.0 0.8 1.0 1.3 2.5 \n", + "2 5.1 1.7 1.1 0.4 1.7 2.4 8.3 \n", + "3 4.9 1.4 1.4 0.4 2.5 2.5 10.9 \n", + "4 3.7 1.3 1.5 0.2 1.8 3.0 9.4 \n", + "\n", + " is_playoffs \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + "\n", + "[5 rows x 28 columns]" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "df = player.stats_per_game(kind='P', level='E')\n", + "\n", + "print(len(df))" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_nameggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_g...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gis_playoffs
02008/euro/teams/valencia/2008.htmlULEB Cup14.0NaN16.61.84.00.4460.6...0.42.12.50.60.90.61.31.44.4True
12009/euro/teams/valencia/2009.htmlEuroCup4.0NaN15.81.32.80.4550.0...0.02.52.51.50.00.81.01.32.5True
22010/euro/teams/valencia/2010.htmlEuroCup16.0NaN26.12.96.90.4271.0...1.23.95.11.71.10.41.72.48.3True
32011/euro/teams/valencia/2011.htmlEuroLeague14.0NaN27.63.67.70.4721.0...0.93.94.91.41.40.42.52.510.9True
42012/euro/teams/valencia/2012.htmlEuroCup10.0NaN27.33.17.70.4031.2...1.22.53.71.31.50.21.83.09.4True
\n", + "

5 rows × 28 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name g gs mp_per_g \\\n", + "0 2008 /euro/teams/valencia/2008.html ULEB Cup 14.0 NaN 16.6 \n", + "1 2009 /euro/teams/valencia/2009.html EuroCup 4.0 NaN 15.8 \n", + "2 2010 /euro/teams/valencia/2010.html EuroCup 16.0 NaN 26.1 \n", + "3 2011 /euro/teams/valencia/2011.html EuroLeague 14.0 NaN 27.6 \n", + "4 2012 /euro/teams/valencia/2012.html EuroCup 10.0 NaN 27.3 \n", + "\n", + " fg_per_g fga_per_g fg_pct fg3_per_g ... orb_per_g drb_per_g \\\n", + "0 1.8 4.0 0.446 0.6 ... 0.4 2.1 \n", + "1 1.3 2.8 0.455 0.0 ... 0.0 2.5 \n", + "2 2.9 6.9 0.427 1.0 ... 1.2 3.9 \n", + "3 3.6 7.7 0.472 1.0 ... 0.9 3.9 \n", + "4 3.1 7.7 0.403 1.2 ... 1.2 2.5 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 2.5 0.6 0.9 0.6 1.3 1.4 4.4 \n", + "1 2.5 1.5 0.0 0.8 1.0 1.3 2.5 \n", + "2 5.1 1.7 1.1 0.4 1.7 2.4 8.3 \n", + "3 4.9 1.4 1.4 0.4 2.5 2.5 10.9 \n", + "4 3.7 1.3 1.5 0.2 1.8 3.0 9.4 \n", + "\n", + " is_playoffs \n", + "0 True \n", + "1 True \n", + "2 True \n", + "3 True \n", + "4 True \n", + "\n", + "[5 rows x 28 columns]" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## stats_totals and stats_per36 params are the same as stats_per_game shown above" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_nameggsmpfgfgafg_pctfg3...orbdrbtrbaststlblktovpfptsis_playoffs
02008/euro/teams/valencia/2008.htmlULEB Cup14.0NaN232.025.056.00.4468.0...6.029.035.09.013.08.018.019.061.0True
12009/euro/teams/valencia/2009.htmlEuroCup4.0NaN63.05.011.00.4550.0...0.010.010.06.00.03.04.05.010.0True
22010/euro/teams/valencia/2010.htmlEuroCup16.0NaN418.047.0110.00.42716.0...19.062.081.027.017.07.027.039.0132.0True
32011/euro/teams/valencia/2011.htmlEuroLeague14.0NaN386.051.0108.00.47214.0...13.055.068.019.020.05.035.035.0153.0True
42012/euro/teams/valencia/2012.htmlEuroCup10.0NaN273.031.077.00.40312.0...12.025.037.013.015.02.018.030.094.0True
\n", + "

5 rows × 28 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name g gs mp fg \\\n", + "0 2008 /euro/teams/valencia/2008.html ULEB Cup 14.0 NaN 232.0 25.0 \n", + "1 2009 /euro/teams/valencia/2009.html EuroCup 4.0 NaN 63.0 5.0 \n", + "2 2010 /euro/teams/valencia/2010.html EuroCup 16.0 NaN 418.0 47.0 \n", + "3 2011 /euro/teams/valencia/2011.html EuroLeague 14.0 NaN 386.0 51.0 \n", + "4 2012 /euro/teams/valencia/2012.html EuroCup 10.0 NaN 273.0 31.0 \n", + "\n", + " fga fg_pct fg3 ... orb drb trb ast stl blk tov \\\n", + "0 56.0 0.446 8.0 ... 6.0 29.0 35.0 9.0 13.0 8.0 18.0 \n", + "1 11.0 0.455 0.0 ... 0.0 10.0 10.0 6.0 0.0 3.0 4.0 \n", + "2 110.0 0.427 16.0 ... 19.0 62.0 81.0 27.0 17.0 7.0 27.0 \n", + "3 108.0 0.472 14.0 ... 13.0 55.0 68.0 19.0 20.0 5.0 35.0 \n", + "4 77.0 0.403 12.0 ... 12.0 25.0 37.0 13.0 15.0 2.0 18.0 \n", + "\n", + " pf pts is_playoffs \n", + "0 19.0 61.0 True \n", + "1 5.0 10.0 True \n", + "2 39.0 132.0 True \n", + "3 35.0 153.0 True \n", + "4 30.0 94.0 True \n", + "\n", + "[5 rows x 28 columns]" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "player.stats_totals(kind='P', level='E').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
seasonteam_name_seasonlg_nameggsmpfg_per_mpfga_per_mpfg_pctfg3_per_mp...orb_per_mpdrb_per_mptrb_per_mpast_per_mpstl_per_mpblk_per_mptov_per_mppf_per_mppts_per_mpis_playoffs
02008/euro/teams/valencia/2008.htmlULEB Cup14.0NaN232.03.98.70.4461.2...0.94.55.41.42.01.22.82.99.5True
12009/euro/teams/valencia/2009.htmlEuroCup4.0NaN63.02.96.30.4550.0...0.05.75.73.40.01.72.32.95.7True
22010/euro/teams/valencia/2010.htmlEuroCup16.0NaN418.04.09.50.4271.4...1.65.37.02.31.50.62.33.411.4True
32011/euro/teams/valencia/2011.htmlEuroLeague14.0NaN386.04.810.10.4721.3...1.25.16.31.81.90.53.33.314.3True
42012/euro/teams/valencia/2012.htmlEuroCup10.0NaN273.04.110.20.4031.6...1.63.34.91.72.00.32.44.012.4True
\n", + "

5 rows × 28 columns

\n", + "
" + ], + "text/plain": [ + " season team_name_season lg_name g gs mp \\\n", + "0 2008 /euro/teams/valencia/2008.html ULEB Cup 14.0 NaN 232.0 \n", + "1 2009 /euro/teams/valencia/2009.html EuroCup 4.0 NaN 63.0 \n", + "2 2010 /euro/teams/valencia/2010.html EuroCup 16.0 NaN 418.0 \n", + "3 2011 /euro/teams/valencia/2011.html EuroLeague 14.0 NaN 386.0 \n", + "4 2012 /euro/teams/valencia/2012.html EuroCup 10.0 NaN 273.0 \n", + "\n", + " fg_per_mp fga_per_mp fg_pct fg3_per_mp ... orb_per_mp \\\n", + "0 3.9 8.7 0.446 1.2 ... 0.9 \n", + "1 2.9 6.3 0.455 0.0 ... 0.0 \n", + "2 4.0 9.5 0.427 1.4 ... 1.6 \n", + "3 4.8 10.1 0.472 1.3 ... 1.2 \n", + "4 4.1 10.2 0.403 1.6 ... 1.6 \n", + "\n", + " drb_per_mp trb_per_mp ast_per_mp stl_per_mp blk_per_mp tov_per_mp \\\n", + "0 4.5 5.4 1.4 2.0 1.2 2.8 \n", + "1 5.7 5.7 3.4 0.0 1.7 2.3 \n", + "2 5.3 7.0 2.3 1.5 0.6 2.3 \n", + "3 5.1 6.3 1.8 1.9 0.5 3.3 \n", + "4 3.3 4.9 1.7 2.0 0.3 2.4 \n", + "\n", + " pf_per_mp pts_per_mp is_playoffs \n", + "0 2.9 9.5 True \n", + "1 2.9 5.7 True \n", + "2 3.4 11.4 True \n", + "3 3.3 14.3 True \n", + "4 4.0 12.4 True \n", + "\n", + "[5 rows x 28 columns]" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "player.stats_per36(kind='P', level='E').head()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/test_notebooks/euro/euro_season_test.ipynb b/test_notebooks/euro/euro_season_test.ipynb new file mode 100644 index 0000000..abd08ab --- /dev/null +++ b/test_notebooks/euro/euro_season_test.ipynb @@ -0,0 +1,1255 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# euro.Season test notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "from sportsref import euro" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Need league_id to initialize - list of league_ids can be obtained with euro.LEAGUE_IDS" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['greek-basket-league', 'eurocup', 'spain-liga-acb', 'italy-basket-serie-a', 'france-lnb-pro-a', 'euroleague']\n" + ] + } + ], + "source": [ + "print(euro.LEAGUE_IDS)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "season = euro.Season(2017, 'france-lnb-pro-a', )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Helper methods" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['chalon', 'strasbourg', 'villeurbanne', 'monaco', 'paris-levallois', 'nanterre', 'gravelines', 'chalons-en-champagne', 'limoges', 'nancy', 'cholet', 'dijon', 'orleans', 'le-mans', 'pau-orthez', 'le-portel', 'hyeres-toulon', 'antibes']\n" + ] + } + ], + "source": [ + "print(season.get_team_ids())" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'chalon': 'Chalon/Saone', 'strasbourg': 'Strasbourg', 'villeurbanne': 'Lyon-Villeurbanne', 'monaco': 'Monaco', 'paris-levallois': 'Paris-Levallois', 'nanterre': 'Nanterre', 'gravelines': 'Gravelines-Dunkerque', 'chalons-en-champagne': 'Chalons-Reims', 'limoges': 'Limoges', 'nancy': 'Nancy', 'cholet': 'Cholet', 'dijon': 'Dijon', 'orleans': 'Orleans', 'le-mans': 'Le Mans', 'pau-orthez': 'Pau-Lacq-Orthez', 'le-portel': 'Le Portel', 'hyeres-toulon': 'Hyeres-Toulon', 'antibes': 'Antibes'}\n" + ] + } + ], + "source": [ + "print(season.team_ids_to_names())" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Chalon/Saone': 'chalon', 'Strasbourg': 'strasbourg', 'Lyon-Villeurbanne': 'villeurbanne', 'Monaco': 'monaco', 'Paris-Levallois': 'paris-levallois', 'Nanterre': 'nanterre', 'Gravelines-Dunkerque': 'gravelines', 'Chalons-Reims': 'chalons-en-champagne', 'Limoges': 'limoges', 'Nancy': 'nancy', 'Cholet': 'cholet', 'Dijon': 'dijon', 'Orleans': 'orleans', 'Le Mans': 'le-mans', 'Pau-Lacq-Orthez': 'pau-orthez', 'Le Portel': 'le-portel', 'Hyeres-Toulon': 'hyeres-toulon', 'Antibes': 'antibes'}\n" + ] + } + ], + "source": [ + "print(season.team_names_to_ids())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Schedule\n", + "\n", + "### takes kind argument: \n", + "#### R (Club play)\n", + "#### P (Euroleague play)\n", + "#### B (both)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "347\n", + "24\n", + "323\n" + ] + } + ], + "source": [ + "print(len(season.schedule(kind='B')))\n", + "print(len(season.schedule(kind='P')))\n", + "print(len(season.schedule(kind='R')))" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
boxscore_idvisitor_team_namevisitor_ptshome_team_namehome_ptsboxscore_idovertimesnotesis_playoffs
02016-09-23-hyeres-toulonGravelines-Dunkerque62.0Hyeres-Toulon75.0NaNNaNNaNFalse
12016-09-23-le-portelNanterre84.0Le Portel65.0NaNNaNNaNFalse
22016-09-23-paris-levalloisNancy67.0Paris-Levallois75.0NaNNaNNaNFalse
32016-09-24-chalonOrleans67.0Chalon/Saone87.0NaNNaNNaNFalse
42016-09-24-chalons-en-champagneAntibes92.0Chalons-Reims77.0NaNNaNNaNFalse
\n", + "
" + ], + "text/plain": [ + " boxscore_id visitor_team_name visitor_pts \\\n", + "0 2016-09-23-hyeres-toulon Gravelines-Dunkerque 62.0 \n", + "1 2016-09-23-le-portel Nanterre 84.0 \n", + "2 2016-09-23-paris-levallois Nancy 67.0 \n", + "3 2016-09-24-chalon Orleans 67.0 \n", + "4 2016-09-24-chalons-en-champagne Antibes 92.0 \n", + "\n", + " home_team_name home_pts boxscore_id overtimes notes is_playoffs \n", + "0 Hyeres-Toulon 75.0 NaN NaN NaN False \n", + "1 Le Portel 65.0 NaN NaN NaN False \n", + "2 Paris-Levallois 75.0 NaN NaN NaN False \n", + "3 Chalon/Saone 87.0 NaN NaN NaN False \n", + "4 Chalons-Reims 77.0 NaN NaN NaN False " + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.schedule(kind='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
boxscore_idvisitor_team_namevisitor_ptshome_team_namehome_ptsboxscore_idovertimesnotesis_playoffs
02017-05-22-monacoLyon-Villeurbanne72.0Monaco69.0NaNNaNNaNTrue
12017-05-22-strasbourgPau-Lacq-Orthez102.0Strasbourg92.0NaNNaNNaNTrue
22017-05-23-chalonLe Portel63.0Chalon/Saone76.0NaNNaNNaNTrue
32017-05-23-nanterreParis-Levallois88.0Nanterre85.0NaNNaNNaNTrue
42017-05-24-pau-orthezStrasbourg83.0Pau-Lacq-Orthez68.0NaNNaNNaNTrue
\n", + "
" + ], + "text/plain": [ + " boxscore_id visitor_team_name visitor_pts home_team_name \\\n", + "0 2017-05-22-monaco Lyon-Villeurbanne 72.0 Monaco \n", + "1 2017-05-22-strasbourg Pau-Lacq-Orthez 102.0 Strasbourg \n", + "2 2017-05-23-chalon Le Portel 63.0 Chalon/Saone \n", + "3 2017-05-23-nanterre Paris-Levallois 88.0 Nanterre \n", + "4 2017-05-24-pau-orthez Strasbourg 83.0 Pau-Lacq-Orthez \n", + "\n", + " home_pts boxscore_id overtimes notes is_playoffs \n", + "0 69.0 NaN NaN NaN True \n", + "1 92.0 NaN NaN NaN True \n", + "2 76.0 NaN NaN NaN True \n", + "3 85.0 NaN NaN NaN True \n", + "4 68.0 NaN NaN NaN True " + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.schedule(kind='P').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
boxscore_idvisitor_team_namevisitor_ptshome_team_namehome_ptsboxscore_idovertimesnotesis_playoffs
02016-09-23-hyeres-toulonGravelines-Dunkerque62.0Hyeres-Toulon75.0NaNNaNNaNFalse
12016-09-23-le-portelNanterre84.0Le Portel65.0NaNNaNNaNFalse
22016-09-23-paris-levalloisNancy67.0Paris-Levallois75.0NaNNaNNaNFalse
32016-09-24-chalonOrleans67.0Chalon/Saone87.0NaNNaNNaNFalse
42016-09-24-chalons-en-champagneAntibes92.0Chalons-Reims77.0NaNNaNNaNFalse
\n", + "
" + ], + "text/plain": [ + " boxscore_id visitor_team_name visitor_pts \\\n", + "0 2016-09-23-hyeres-toulon Gravelines-Dunkerque 62.0 \n", + "1 2016-09-23-le-portel Nanterre 84.0 \n", + "2 2016-09-23-paris-levallois Nancy 67.0 \n", + "3 2016-09-24-chalon Orleans 67.0 \n", + "4 2016-09-24-chalons-en-champagne Antibes 92.0 \n", + "\n", + " home_team_name home_pts boxscore_id overtimes notes is_playoffs \n", + "0 Hyeres-Toulon 75.0 NaN NaN NaN False \n", + "1 Le Portel 65.0 NaN NaN NaN False \n", + "2 Paris-Levallois 75.0 NaN NaN NaN False \n", + "3 Chalon/Saone 87.0 NaN NaN NaN False \n", + "4 Chalons-Reims 77.0 NaN NaN NaN False " + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.schedule(kind='R').head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Standings (no args)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
winslosseswin_loss_pctgbpts_per_gopp_pts_per_gwins_pythlosses_pythwins_playoffslosses_playoffswin_loss_pct_playoffspts_per_g_playoffsopp_pts_per_g_playoffswins_pyth_playoffslosses_pyth_playoffshas_class_full_table
team_id
monaco30.04.00.88290.679.929.05.0NaN1.02.00.33370.370.71.02.0True
chalon27.07.00.7943109.699.527.07.0NaN8.03.00.72777.772.08.03.0True
nanterre25.09.00.735585.980.724.010.0NaN0.02.00.00078.082.51.01.0True
strasbourg23.011.00.6767107.5101.024.010.0NaN7.06.00.53874.274.46.07.0True
pau-orthez21.012.00.6368.585.582.021.012.0NaN1.02.00.33379.382.31.02.0True
\n", + "
" + ], + "text/plain": [ + " wins losses win_loss_pct gb pts_per_g opp_pts_per_g \\\n", + "team_id \n", + "monaco 30.0 4.0 0.882 — 90.6 79.9 \n", + "chalon 27.0 7.0 0.794 3 109.6 99.5 \n", + "nanterre 25.0 9.0 0.735 5 85.9 80.7 \n", + "strasbourg 23.0 11.0 0.676 7 107.5 101.0 \n", + "pau-orthez 21.0 12.0 0.636 8.5 85.5 82.0 \n", + "\n", + " wins_pyth losses_pyth wins_playoffs losses_playoffs \\\n", + "team_id \n", + "monaco 29.0 5.0 NaN 1.0 2.0 \n", + "chalon 27.0 7.0 NaN 8.0 3.0 \n", + "nanterre 24.0 10.0 NaN 0.0 2.0 \n", + "strasbourg 24.0 10.0 NaN 7.0 6.0 \n", + "pau-orthez 21.0 12.0 NaN 1.0 2.0 \n", + "\n", + " win_loss_pct_playoffs pts_per_g_playoffs opp_pts_per_g_playoffs \\\n", + "team_id \n", + "monaco 0.333 70.3 70.7 \n", + "chalon 0.727 77.7 72.0 \n", + "nanterre 0.000 78.0 82.5 \n", + "strasbourg 0.538 74.2 74.4 \n", + "pau-orthez 0.333 79.3 82.3 \n", + "\n", + " wins_pyth_playoffs losses_pyth_playoffs has_class_full_table \n", + "team_id \n", + "monaco 1.0 2.0 True \n", + "chalon 8.0 3.0 True \n", + "nanterre 1.0 1.0 True \n", + "strasbourg 6.0 7.0 True \n", + "pau-orthez 1.0 2.0 True " + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.standings().head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## team stat tables (no args)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
gfgfgafg_pctfg3fg3afg3_pctfg2fg2afg2_pct...ft_pctorbdrbtrbaststlblktovpfpts
team_id
chalon34.01381.02770.00.499357.0968.00.3691024.01802.00.568...0.706378.01117.01495.0819.0240.0159.0512.0738.03726.0
strasbourg34.01335.02900.00.460365.0969.00.377970.01931.00.502...0.704461.01096.01557.0894.0329.0123.0584.0977.03654.0
villeurbanne34.01107.02437.00.454299.0868.00.344808.01569.00.515...0.747340.01003.01343.0733.0259.0122.0559.0835.03107.0
monaco34.01107.02417.00.458306.0861.00.355801.01556.00.515...0.742439.0819.01258.0693.0326.0130.0448.0806.03080.0
paris-levallois34.01142.02524.00.452252.0768.00.328890.01756.00.507...0.696426.0979.01405.0642.0245.0109.0506.0844.03061.0
\n", + "

5 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " g fg fga fg_pct fg3 fg3a fg3_pct fg2 \\\n", + "team_id \n", + "chalon 34.0 1381.0 2770.0 0.499 357.0 968.0 0.369 1024.0 \n", + "strasbourg 34.0 1335.0 2900.0 0.460 365.0 969.0 0.377 970.0 \n", + "villeurbanne 34.0 1107.0 2437.0 0.454 299.0 868.0 0.344 808.0 \n", + "monaco 34.0 1107.0 2417.0 0.458 306.0 861.0 0.355 801.0 \n", + "paris-levallois 34.0 1142.0 2524.0 0.452 252.0 768.0 0.328 890.0 \n", + "\n", + " fg2a fg2_pct ... ft_pct orb drb trb \\\n", + "team_id ... \n", + "chalon 1802.0 0.568 ... 0.706 378.0 1117.0 1495.0 \n", + "strasbourg 1931.0 0.502 ... 0.704 461.0 1096.0 1557.0 \n", + "villeurbanne 1569.0 0.515 ... 0.747 340.0 1003.0 1343.0 \n", + "monaco 1556.0 0.515 ... 0.742 439.0 819.0 1258.0 \n", + "paris-levallois 1756.0 0.507 ... 0.696 426.0 979.0 1405.0 \n", + "\n", + " ast stl blk tov pf pts \n", + "team_id \n", + "chalon 819.0 240.0 159.0 512.0 738.0 3726.0 \n", + "strasbourg 894.0 329.0 123.0 584.0 977.0 3654.0 \n", + "villeurbanne 733.0 259.0 122.0 559.0 835.0 3107.0 \n", + "monaco 693.0 326.0 130.0 448.0 806.0 3080.0 \n", + "paris-levallois 642.0 245.0 109.0 506.0 844.0 3061.0 \n", + "\n", + "[5 rows x 22 columns]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.team_stats_totals().head()" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
gfg_per_gfga_per_gfg_pctfg3_per_gfg3a_per_gfg3_pctfg2_per_gfg2a_per_gfg2_pct...ft_pctorb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_g
team_id
chalon34.040.681.50.49910.528.50.36930.153.00.568...0.70611.132.944.024.17.14.715.121.7109.6
strasbourg34.039.385.30.46010.728.50.37728.556.80.502...0.70413.632.245.826.39.73.617.228.7107.5
villeurbanne34.032.671.70.4548.825.50.34423.846.10.515...0.74710.029.539.521.67.63.616.424.691.4
monaco34.032.671.10.4589.025.30.35523.645.80.515...0.74212.924.137.020.49.63.813.223.790.6
paris-levallois34.033.674.20.4527.422.60.32826.251.60.507...0.69612.528.841.318.97.23.214.924.890.0
\n", + "

5 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " g fg_per_g fga_per_g fg_pct fg3_per_g fg3a_per_g \\\n", + "team_id \n", + "chalon 34.0 40.6 81.5 0.499 10.5 28.5 \n", + "strasbourg 34.0 39.3 85.3 0.460 10.7 28.5 \n", + "villeurbanne 34.0 32.6 71.7 0.454 8.8 25.5 \n", + "monaco 34.0 32.6 71.1 0.458 9.0 25.3 \n", + "paris-levallois 34.0 33.6 74.2 0.452 7.4 22.6 \n", + "\n", + " fg3_pct fg2_per_g fg2a_per_g fg2_pct ... ft_pct \\\n", + "team_id ... \n", + "chalon 0.369 30.1 53.0 0.568 ... 0.706 \n", + "strasbourg 0.377 28.5 56.8 0.502 ... 0.704 \n", + "villeurbanne 0.344 23.8 46.1 0.515 ... 0.747 \n", + "monaco 0.355 23.6 45.8 0.515 ... 0.742 \n", + "paris-levallois 0.328 26.2 51.6 0.507 ... 0.696 \n", + "\n", + " orb_per_g drb_per_g trb_per_g ast_per_g stl_per_g \\\n", + "team_id \n", + "chalon 11.1 32.9 44.0 24.1 7.1 \n", + "strasbourg 13.6 32.2 45.8 26.3 9.7 \n", + "villeurbanne 10.0 29.5 39.5 21.6 7.6 \n", + "monaco 12.9 24.1 37.0 20.4 9.6 \n", + "paris-levallois 12.5 28.8 41.3 18.9 7.2 \n", + "\n", + " blk_per_g tov_per_g pf_per_g pts_per_g \n", + "team_id \n", + "chalon 4.7 15.1 21.7 109.6 \n", + "strasbourg 3.6 17.2 28.7 107.5 \n", + "villeurbanne 3.6 16.4 24.6 91.4 \n", + "monaco 3.8 13.2 23.7 90.6 \n", + "paris-levallois 3.2 14.9 24.8 90.0 \n", + "\n", + "[5 rows x 22 columns]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "season.team_stats_per_game().head()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/test_notebooks/euro/euro_team_test.ipynb b/test_notebooks/euro/euro_team_test.ipynb new file mode 100644 index 0000000..7848cba --- /dev/null +++ b/test_notebooks/euro/euro_team_test.ipynb @@ -0,0 +1,1759 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# euro.Team test" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Regenerating PSFConstants file\n", + "Regenerating GPFConstants file\n" + ] + } + ], + "source": [ + "from sportsref import euro" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "team = euro.Team('barcelona')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Helper methods" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "spain-liga-acb\n", + "FC Barcelona\n" + ] + } + ], + "source": [ + "print(team.get_league_id())\n", + "print(team.name())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tables are slightly different than player - because there is no playoff/reg season separate tables (just different pages distinguishing level of competition), no kind param, just level (no concatenation w kind_rpb needed) \n", + "\n", + "## In general, used kind when concatenation made sense, and level when it didn't (needed 2 different params because in player, both needed)\n", + "\n", + "### See https://www.basketball-reference.com/euro/teams/barcelona/2017_euroleague.html\n", + "\n", + "### 'E' = Euroleague\n", + "### 'C' = Club play\n", + "### 'B' = both (combined in 1 table, not concatenated together like playoff/reg season tables)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## all team and opp stats table:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
team_idgmpfgfgafg_pctfg3fg3afg3_pctfg2...ft_pctorbdrbtrbaststlblktovpfpts
0Team62.013100.01795.03812.00.471586.01579.00.3711209.0...0.744515.01510.02025.01084.0437.0140.0884.01313.04988.0
1Opponent62.013100.01754.04013.00.437584.01623.00.3601170.0...0.763573.01368.01941.01039.0453.0109.0779.01318.04897.0
\n", + "

2 rows × 24 columns

\n", + "
" + ], + "text/plain": [ + " team_id g mp fg fga fg_pct fg3 fg3a fg3_pct \\\n", + "0 Team 62.0 13100.0 1795.0 3812.0 0.471 586.0 1579.0 0.371 \n", + "1 Opponent 62.0 13100.0 1754.0 4013.0 0.437 584.0 1623.0 0.360 \n", + "\n", + " fg2 ... ft_pct orb drb trb ast stl blk tov \\\n", + "0 1209.0 ... 0.744 515.0 1510.0 2025.0 1084.0 437.0 140.0 884.0 \n", + "1 1170.0 ... 0.763 573.0 1368.0 1941.0 1039.0 453.0 109.0 779.0 \n", + "\n", + " pf pts \n", + "0 1313.0 4988.0 \n", + "1 1318.0 4897.0 \n", + "\n", + "[2 rows x 24 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.all_team_opp_stats(2017, level='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
team_idgmpfgfgafg_pctfg3fg3afg3_pctfg2...ft_pctorbdrbtrbaststlblktovpfpts
0Team30.06025.0767.01739.00.441271.0716.00.378496.0...0.737245.0680.0925.0517.0212.061.0420.0553.02141.0
1Opponent30.06025.0834.01844.00.452263.0729.00.361571.0...0.748254.0659.0913.0510.0232.065.0357.0599.02242.0
\n", + "

2 rows × 24 columns

\n", + "
" + ], + "text/plain": [ + " team_id g mp fg fga fg_pct fg3 fg3a fg3_pct \\\n", + "0 Team 30.0 6025.0 767.0 1739.0 0.441 271.0 716.0 0.378 \n", + "1 Opponent 30.0 6025.0 834.0 1844.0 0.452 263.0 729.0 0.361 \n", + "\n", + " fg2 ... ft_pct orb drb trb ast stl blk tov \\\n", + "0 496.0 ... 0.737 245.0 680.0 925.0 517.0 212.0 61.0 420.0 \n", + "1 571.0 ... 0.748 254.0 659.0 913.0 510.0 232.0 65.0 357.0 \n", + "\n", + " pf pts \n", + "0 553.0 2141.0 \n", + "1 599.0 2242.0 \n", + "\n", + "[2 rows x 24 columns]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.all_team_opp_stats(2017, level='E').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
team_idgmpfgfgafg_pctfg3fg3afg3_pctfg2...ft_pctorbdrbtrbaststlblktovpfpts
0Team32.07075.01028.02073.00.496315.0863.00.365713.0...0.748270.0830.01100.0567.0225.079.0464.0760.02847.0
1Opponent32.07075.0920.02169.00.424321.0894.00.359599.0...0.773319.0709.01028.0529.0221.044.0422.0719.02655.0
\n", + "

2 rows × 24 columns

\n", + "
" + ], + "text/plain": [ + " team_id g mp fg fga fg_pct fg3 fg3a fg3_pct \\\n", + "0 Team 32.0 7075.0 1028.0 2073.0 0.496 315.0 863.0 0.365 \n", + "1 Opponent 32.0 7075.0 920.0 2169.0 0.424 321.0 894.0 0.359 \n", + "\n", + " fg2 ... ft_pct orb drb trb ast stl blk tov \\\n", + "0 713.0 ... 0.748 270.0 830.0 1100.0 567.0 225.0 79.0 464.0 \n", + "1 599.0 ... 0.773 319.0 709.0 1028.0 529.0 221.0 44.0 422.0 \n", + "\n", + " pf pts \n", + "0 760.0 2847.0 \n", + "1 719.0 2655.0 \n", + "\n", + "[2 rows x 24 columns]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.all_team_opp_stats(2017, level='C').head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Other stats tables have same level param" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idggsmp_per_gfg_per_gfga_per_gfg_pctfg3_per_gfg3a_per_gfg3_pct...orb_per_gdrb_per_gtrb_per_gast_per_gstl_per_gblk_per_gtov_per_gpf_per_gpts_per_gplayer_name
0tyrese-rice-161.0NaN27.54.210.80.3901.65.20.307...0.21.31.64.11.00.12.52.312.3Tyrese Rice
1ante-tomic-161.0NaN22.44.37.30.5900.00.00.333...2.14.86.92.00.60.61.62.210.8Ante Tomic
2petteri-koponen-154.0NaN22.13.17.20.4361.63.80.417...0.31.71.92.10.70.11.31.99.4Petteri Koponen
3victor-claver-156.0NaN21.22.04.30.4710.92.20.395...0.83.44.31.20.90.41.32.05.5Victor Claver
4aleksandar-vezenkov-162.0NaN18.63.05.50.5531.12.70.420...0.92.33.21.00.60.20.71.98.3Aleksandar Vezenkov
\n", + "

5 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " player_id g gs mp_per_g fg_per_g fga_per_g fg_pct \\\n", + "0 tyrese-rice-1 61.0 NaN 27.5 4.2 10.8 0.390 \n", + "1 ante-tomic-1 61.0 NaN 22.4 4.3 7.3 0.590 \n", + "2 petteri-koponen-1 54.0 NaN 22.1 3.1 7.2 0.436 \n", + "3 victor-claver-1 56.0 NaN 21.2 2.0 4.3 0.471 \n", + "4 aleksandar-vezenkov-1 62.0 NaN 18.6 3.0 5.5 0.553 \n", + "\n", + " fg3_per_g fg3a_per_g fg3_pct ... orb_per_g drb_per_g \\\n", + "0 1.6 5.2 0.307 ... 0.2 1.3 \n", + "1 0.0 0.0 0.333 ... 2.1 4.8 \n", + "2 1.6 3.8 0.417 ... 0.3 1.7 \n", + "3 0.9 2.2 0.395 ... 0.8 3.4 \n", + "4 1.1 2.7 0.420 ... 0.9 2.3 \n", + "\n", + " trb_per_g ast_per_g stl_per_g blk_per_g tov_per_g pf_per_g pts_per_g \\\n", + "0 1.6 4.1 1.0 0.1 2.5 2.3 12.3 \n", + "1 6.9 2.0 0.6 0.6 1.6 2.2 10.8 \n", + "2 1.9 2.1 0.7 0.1 1.3 1.9 9.4 \n", + "3 4.3 1.2 0.9 0.4 1.3 2.0 5.5 \n", + "4 3.2 1.0 0.6 0.2 0.7 1.9 8.3 \n", + "\n", + " player_name \n", + "0 Tyrese Rice \n", + "1 Ante Tomic \n", + "2 Petteri Koponen \n", + "3 Victor Claver \n", + "4 Aleksandar Vezenkov \n", + "\n", + "[5 rows x 26 columns]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.stats_per_game(2017, level='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idggsmpfgfgafg_pctfg3fg3afg3_pct...orbdrbtrbaststlblktovpfptsplayer_name
0tyrese-rice-161.0NaN1680.0256.0657.00.39098.0319.00.307...15.080.095.0252.058.04.0151.0142.0750.0Tyrese Rice
1ante-tomic-161.0NaN1367.0262.0444.00.5901.03.00.333...128.0295.0423.0124.035.036.099.0135.0661.0Ante Tomic
2petteri-koponen-154.0NaN1196.0169.0388.00.43685.0204.00.417...15.090.0105.0112.039.03.071.0100.0509.0Petteri Koponen
3victor-claver-156.0NaN1187.0112.0238.00.47149.0124.00.395...46.0192.0238.069.051.024.074.0111.0309.0Victor Claver
4aleksandar-vezenkov-162.0NaN1156.0187.0338.00.55371.0169.00.420...55.0143.0198.061.037.015.045.0115.0513.0Aleksandar Vezenkov
\n", + "

5 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " player_id g gs mp fg fga fg_pct fg3 fg3a \\\n", + "0 tyrese-rice-1 61.0 NaN 1680.0 256.0 657.0 0.390 98.0 319.0 \n", + "1 ante-tomic-1 61.0 NaN 1367.0 262.0 444.0 0.590 1.0 3.0 \n", + "2 petteri-koponen-1 54.0 NaN 1196.0 169.0 388.0 0.436 85.0 204.0 \n", + "3 victor-claver-1 56.0 NaN 1187.0 112.0 238.0 0.471 49.0 124.0 \n", + "4 aleksandar-vezenkov-1 62.0 NaN 1156.0 187.0 338.0 0.553 71.0 169.0 \n", + "\n", + " fg3_pct ... orb drb trb ast stl blk \\\n", + "0 0.307 ... 15.0 80.0 95.0 252.0 58.0 4.0 \n", + "1 0.333 ... 128.0 295.0 423.0 124.0 35.0 36.0 \n", + "2 0.417 ... 15.0 90.0 105.0 112.0 39.0 3.0 \n", + "3 0.395 ... 46.0 192.0 238.0 69.0 51.0 24.0 \n", + "4 0.420 ... 55.0 143.0 198.0 61.0 37.0 15.0 \n", + "\n", + " tov pf pts player_name \n", + "0 151.0 142.0 750.0 Tyrese Rice \n", + "1 99.0 135.0 661.0 Ante Tomic \n", + "2 71.0 100.0 509.0 Petteri Koponen \n", + "3 74.0 111.0 309.0 Victor Claver \n", + "4 45.0 115.0 513.0 Aleksandar Vezenkov \n", + "\n", + "[5 rows x 26 columns]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.stats_totals(2017, level='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idggsmpfg_per_mpfga_per_mpfg_pctfg3_per_mpfg3a_per_mpfg3_pct...orb_per_mpdrb_per_mptrb_per_mpast_per_mpstl_per_mpblk_per_mptov_per_mppf_per_mppts_per_mpplayer_name
0tyrese-rice-161.0NaN1680.05.514.10.3902.16.80.307...0.31.72.05.41.20.13.23.016.1Tyrese Rice
1ante-tomic-161.0NaN1367.06.911.70.5900.00.10.333...3.47.811.13.30.90.92.63.617.4Ante Tomic
2petteri-koponen-154.0NaN1196.05.111.70.4362.66.10.417...0.52.73.23.41.20.12.13.015.3Petteri Koponen
3victor-claver-156.0NaN1187.03.47.20.4711.53.80.395...1.45.87.22.11.50.72.23.49.4Victor Claver
4aleksandar-vezenkov-162.0NaN1156.05.810.50.5532.25.30.420...1.74.56.21.91.20.51.43.616.0Aleksandar Vezenkov
\n", + "

5 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " player_id g gs mp fg_per_mp fga_per_mp fg_pct \\\n", + "0 tyrese-rice-1 61.0 NaN 1680.0 5.5 14.1 0.390 \n", + "1 ante-tomic-1 61.0 NaN 1367.0 6.9 11.7 0.590 \n", + "2 petteri-koponen-1 54.0 NaN 1196.0 5.1 11.7 0.436 \n", + "3 victor-claver-1 56.0 NaN 1187.0 3.4 7.2 0.471 \n", + "4 aleksandar-vezenkov-1 62.0 NaN 1156.0 5.8 10.5 0.553 \n", + "\n", + " fg3_per_mp fg3a_per_mp fg3_pct ... orb_per_mp \\\n", + "0 2.1 6.8 0.307 ... 0.3 \n", + "1 0.0 0.1 0.333 ... 3.4 \n", + "2 2.6 6.1 0.417 ... 0.5 \n", + "3 1.5 3.8 0.395 ... 1.4 \n", + "4 2.2 5.3 0.420 ... 1.7 \n", + "\n", + " drb_per_mp trb_per_mp ast_per_mp stl_per_mp blk_per_mp tov_per_mp \\\n", + "0 1.7 2.0 5.4 1.2 0.1 3.2 \n", + "1 7.8 11.1 3.3 0.9 0.9 2.6 \n", + "2 2.7 3.2 3.4 1.2 0.1 2.1 \n", + "3 5.8 7.2 2.1 1.5 0.7 2.2 \n", + "4 4.5 6.2 1.9 1.2 0.5 1.4 \n", + "\n", + " pf_per_mp pts_per_mp player_name \n", + "0 3.0 16.1 Tyrese Rice \n", + "1 3.6 17.4 Ante Tomic \n", + "2 3.0 15.3 Petteri Koponen \n", + "3 3.4 9.4 Victor Claver \n", + "4 3.6 16.0 Aleksandar Vezenkov \n", + "\n", + "[5 rows x 26 columns]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.stats_per36(2017, level='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
player_idgmpts_pctefg_pctfg3a_per_fga_pctfta_per_fga_pctast_pcttov_pctusg_pctplayer_name
0tyrese-rice-161.01680.00.511NaN0.4860.26531.017.126.9Tyrese Rice
1ante-tomic-161.01367.00.605NaN0.0070.52520.415.324.1Ante Tomic
2petteri-koponen-154.01196.00.593NaN0.5260.24218.914.221.4Petteri Koponen
3victor-claver-156.01187.00.594NaN0.5210.21010.722.214.4Victor Claver
4aleksandar-vezenkov-162.01156.00.686NaN0.5000.24011.110.718.5Aleksandar Vezenkov
\n", + "
" + ], + "text/plain": [ + " player_id g mp ts_pct efg_pct fg3a_per_fga_pct \\\n", + "0 tyrese-rice-1 61.0 1680.0 0.511 NaN 0.486 \n", + "1 ante-tomic-1 61.0 1367.0 0.605 NaN 0.007 \n", + "2 petteri-koponen-1 54.0 1196.0 0.593 NaN 0.526 \n", + "3 victor-claver-1 56.0 1187.0 0.594 NaN 0.521 \n", + "4 aleksandar-vezenkov-1 62.0 1156.0 0.686 NaN 0.500 \n", + "\n", + " fta_per_fga_pct ast_pct tov_pct usg_pct player_name \n", + "0 0.265 31.0 17.1 26.9 Tyrese Rice \n", + "1 0.525 20.4 15.3 24.1 Ante Tomic \n", + "2 0.242 18.9 14.2 21.4 Petteri Koponen \n", + "3 0.210 10.7 22.2 14.4 Victor Claver \n", + "4 0.240 11.1 10.7 18.5 Aleksandar Vezenkov " + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "team.stats_advanced(2017, level='B').head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Schedule: uses kind, because it must be concatenated" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "65\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
gboxscore_idis_homeopp_name_linkgame_resultovertimesptsopp_ptswinslossesgame_streakis_playoffs
01.02016-10-02-manresaFalse/euro/teams/manresa/2017.htmlWNaN56.050.01.00.0W 1False
12.02016-10-09-barcelonaTrue/euro/teams/vitoria/2017.htmlWNaN98.092.02.00.0W 2False
23.02016-10-16-bilbaoFalse/euro/teams/bilbao/2017.htmlLNaN79.092.02.01.0L 1False
34.02016-10-23-barcelonaTrue/euro/teams/sevilla/2017.htmlWNaN80.058.03.01.0W 1False
45.02016-10-30-fuenlabradaFalse/euro/teams/fuenlabrada/2017.htmlWNaN78.075.04.01.0W 2False
\n", + "
" + ], + "text/plain": [ + " g boxscore_id is_home opp_name_link \\\n", + "0 1.0 2016-10-02-manresa False /euro/teams/manresa/2017.html \n", + "1 2.0 2016-10-09-barcelona True /euro/teams/vitoria/2017.html \n", + "2 3.0 2016-10-16-bilbao False /euro/teams/bilbao/2017.html \n", + "3 4.0 2016-10-23-barcelona True /euro/teams/sevilla/2017.html \n", + "4 5.0 2016-10-30-fuenlabrada False /euro/teams/fuenlabrada/2017.html \n", + "\n", + " game_result overtimes pts opp_pts wins losses game_streak is_playoffs \n", + "0 W NaN 56.0 50.0 1.0 0.0 W 1 False \n", + "1 W NaN 98.0 92.0 2.0 0.0 W 2 False \n", + "2 L NaN 79.0 92.0 2.0 1.0 L 1 False \n", + "3 W NaN 80.0 58.0 3.0 1.0 W 1 False \n", + "4 W NaN 78.0 75.0 4.0 1.0 W 2 False " + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(len(team.schedule(2017, kind='B')))\n", + "team.schedule(2017, kind='B').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "35\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
gboxscore_idis_homeopp_name_linkgame_resultovertimesptsopp_ptswinslossesgame_streakis_playoffs
01.02016-10-02-manresaFalse/euro/teams/manresa/2017.htmlWNaN56.050.01.00.0W 1False
12.02016-10-09-barcelonaTrue/euro/teams/vitoria/2017.htmlWNaN98.092.02.00.0W 2False
23.02016-10-16-bilbaoFalse/euro/teams/bilbao/2017.htmlLNaN79.092.02.01.0L 1False
34.02016-10-23-barcelonaTrue/euro/teams/sevilla/2017.htmlWNaN80.058.03.01.0W 1False
45.02016-10-30-fuenlabradaFalse/euro/teams/fuenlabrada/2017.htmlWNaN78.075.04.01.0W 2False
\n", + "
" + ], + "text/plain": [ + " g boxscore_id is_home opp_name_link \\\n", + "0 1.0 2016-10-02-manresa False /euro/teams/manresa/2017.html \n", + "1 2.0 2016-10-09-barcelona True /euro/teams/vitoria/2017.html \n", + "2 3.0 2016-10-16-bilbao False /euro/teams/bilbao/2017.html \n", + "3 4.0 2016-10-23-barcelona True /euro/teams/sevilla/2017.html \n", + "4 5.0 2016-10-30-fuenlabrada False /euro/teams/fuenlabrada/2017.html \n", + "\n", + " game_result overtimes pts opp_pts wins losses game_streak is_playoffs \n", + "0 W NaN 56.0 50.0 1.0 0.0 W 1 False \n", + "1 W NaN 98.0 92.0 2.0 0.0 W 2 False \n", + "2 L NaN 79.0 92.0 2.0 1.0 L 1 False \n", + "3 W NaN 80.0 58.0 3.0 1.0 W 1 False \n", + "4 W NaN 78.0 75.0 4.0 1.0 W 2 False " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(len(team.schedule(2017, kind='R')))\n", + "team.schedule(2017, kind='R').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "30\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
gboxscore_idis_homeopp_name_linkgame_resultovertimesptsopp_ptswinslossesgame_streakis_playoffs
01.02016-10-14-unics-kazanFalse/euro/teams/unics-kazan/2017.htmlWNaN69.063.01.00.0W 1True
12.02016-10-21-barcelonaTrue/euro/teams/ulker-fenerbahce/2017.htmlLNaN72.073.01.01.0L 1True
23.02016-10-26-red-starFalse/euro/teams/red-star/2017.htmlLNaN65.076.01.02.0L 2True
34.02016-10-28-barcelonaTrue/euro/teams/brose-baskets/2017.htmlWNaN78.074.02.02.0W 1True
45.02016-11-02-maccabi-tel-avivFalse/euro/teams/maccabi-tel-aviv/2017.htmlWNaN79.069.03.02.0W 2True
\n", + "
" + ], + "text/plain": [ + " g boxscore_id is_home \\\n", + "0 1.0 2016-10-14-unics-kazan False \n", + "1 2.0 2016-10-21-barcelona True \n", + "2 3.0 2016-10-26-red-star False \n", + "3 4.0 2016-10-28-barcelona True \n", + "4 5.0 2016-11-02-maccabi-tel-aviv False \n", + "\n", + " opp_name_link game_result overtimes pts \\\n", + "0 /euro/teams/unics-kazan/2017.html W NaN 69.0 \n", + "1 /euro/teams/ulker-fenerbahce/2017.html L NaN 72.0 \n", + "2 /euro/teams/red-star/2017.html L NaN 65.0 \n", + "3 /euro/teams/brose-baskets/2017.html W NaN 78.0 \n", + "4 /euro/teams/maccabi-tel-aviv/2017.html W NaN 79.0 \n", + "\n", + " opp_pts wins losses game_streak is_playoffs \n", + "0 63.0 1.0 0.0 W 1 True \n", + "1 73.0 1.0 1.0 L 1 True \n", + "2 76.0 1.0 2.0 L 2 True \n", + "3 74.0 2.0 2.0 W 1 True \n", + "4 69.0 3.0 2.0 W 2 True " + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(len(team.schedule(2017, kind='P')))\n", + "team.schedule(2017, kind='P').head()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}