partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
Command.handle
Command handler for the "metrics" command.
analytics/management/commands/statistics.py
def handle(self, *args, **kwargs): """ Command handler for the "metrics" command. """ frequency = kwargs['frequency'] frequencies = settings.STATISTIC_FREQUENCY_ALL if frequency == 'a' else (frequency.split(',') if ',' in frequency else [frequency]) if kwargs['list']: ...
def handle(self, *args, **kwargs): """ Command handler for the "metrics" command. """ frequency = kwargs['frequency'] frequencies = settings.STATISTIC_FREQUENCY_ALL if frequency == 'a' else (frequency.split(',') if ',' in frequency else [frequency]) if kwargs['list']: ...
[ "Command", "handler", "for", "the", "metrics", "command", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/management/commands/statistics.py#L63-L84
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "frequency", "=", "kwargs", "[", "'frequency'", "]", "frequencies", "=", "settings", ".", "STATISTIC_FREQUENCY_ALL", "if", "frequency", "==", "'a'", "else", "(", "frequency"...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
get_GET_array
Returns the GET array's contents for the specified variable.
analytics/geckoboard_views.py
def get_GET_array(request, var_name, fail_silently=True): """ Returns the GET array's contents for the specified variable. """ vals = request.GET.getlist(var_name) if not vals: if fail_silently: return [] else: raise Exception, _("No array called '%(varname)s...
def get_GET_array(request, var_name, fail_silently=True): """ Returns the GET array's contents for the specified variable. """ vals = request.GET.getlist(var_name) if not vals: if fail_silently: return [] else: raise Exception, _("No array called '%(varname)s...
[ "Returns", "the", "GET", "array", "s", "contents", "for", "the", "specified", "variable", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L14-L26
[ "def", "get_GET_array", "(", "request", ",", "var_name", ",", "fail_silently", "=", "True", ")", ":", "vals", "=", "request", ".", "GET", ".", "getlist", "(", "var_name", ")", "if", "not", "vals", ":", "if", "fail_silently", ":", "return", "[", "]", "e...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
get_GET_bool
Tries to extract a boolean variable from the specified request.
analytics/geckoboard_views.py
def get_GET_bool(request, var_name, default=True): """ Tries to extract a boolean variable from the specified request. """ val = request.GET.get(var_name, default) if isinstance(val, str) or isinstance(val, unicode): val = True if val[0] == 't' else False return val
def get_GET_bool(request, var_name, default=True): """ Tries to extract a boolean variable from the specified request. """ val = request.GET.get(var_name, default) if isinstance(val, str) or isinstance(val, unicode): val = True if val[0] == 't' else False return val
[ "Tries", "to", "extract", "a", "boolean", "variable", "from", "the", "specified", "request", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L30-L39
[ "def", "get_GET_bool", "(", "request", ",", "var_name", ",", "default", "=", "True", ")", ":", "val", "=", "request", ".", "GET", ".", "get", "(", "var_name", ",", "default", ")", "if", "isinstance", "(", "val", ",", "str", ")", "or", "isinstance", "...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
get_next_colour
Gets the next colour in the Geckoboard colour list.
analytics/geckoboard_views.py
def get_next_colour(): """ Gets the next colour in the Geckoboard colour list. """ colour = settings.GECKOBOARD_COLOURS[get_next_colour.cur_colour] get_next_colour.cur_colour += 1 if get_next_colour.cur_colour >= len(settings.GECKOBOARD_COLOURS): get_next_colour.cur_colour = 0 ret...
def get_next_colour(): """ Gets the next colour in the Geckoboard colour list. """ colour = settings.GECKOBOARD_COLOURS[get_next_colour.cur_colour] get_next_colour.cur_colour += 1 if get_next_colour.cur_colour >= len(settings.GECKOBOARD_COLOURS): get_next_colour.cur_colour = 0 ret...
[ "Gets", "the", "next", "colour", "in", "the", "Geckoboard", "colour", "list", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L43-L54
[ "def", "get_next_colour", "(", ")", ":", "colour", "=", "settings", ".", "GECKOBOARD_COLOURS", "[", "get_next_colour", ".", "cur_colour", "]", "get_next_colour", ".", "cur_colour", "+=", "1", "if", "get_next_colour", ".", "cur_colour", ">=", "len", "(", "setting...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
get_gecko_params
Returns the default GET parameters for a particular Geckoboard view request.
analytics/geckoboard_views.py
def get_gecko_params(request, uid=None, days_back=0, cumulative=True, frequency=settings.STATISTIC_FREQUENCY_DAILY, min_val=0, max_val=100, chart_type='standard', percentage='show', sort=False): """ Returns the default GET parameters for a particular Geckoboard view request. """ return { ...
def get_gecko_params(request, uid=None, days_back=0, cumulative=True, frequency=settings.STATISTIC_FREQUENCY_DAILY, min_val=0, max_val=100, chart_type='standard', percentage='show', sort=False): """ Returns the default GET parameters for a particular Geckoboard view request. """ return { ...
[ "Returns", "the", "default", "GET", "parameters", "for", "a", "particular", "Geckoboard", "view", "request", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L61-L80
[ "def", "get_gecko_params", "(", "request", ",", "uid", "=", "None", ",", "days_back", "=", "0", ",", "cumulative", "=", "True", ",", "frequency", "=", "settings", ".", "STATISTIC_FREQUENCY_DAILY", ",", "min_val", "=", "0", ",", "max_val", "=", "100", ",", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_number_widget
Returns a number widget for the specified metric's cumulative total.
analytics/geckoboard_views.py
def geckoboard_number_widget(request): """ Returns a number widget for the specified metric's cumulative total. """ params = get_gecko_params(request, days_back=7) metric = Metric.objects.get(uid=params['uid']) try: latest_stat = metric.statistics.filter(frequency=params['frequency']).o...
def geckoboard_number_widget(request): """ Returns a number widget for the specified metric's cumulative total. """ params = get_gecko_params(request, days_back=7) metric = Metric.objects.get(uid=params['uid']) try: latest_stat = metric.statistics.filter(frequency=params['frequency']).o...
[ "Returns", "a", "number", "widget", "for", "the", "specified", "metric", "s", "cumulative", "total", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L87-L106
[ "def", "geckoboard_number_widget", "(", "request", ")", ":", "params", "=", "get_gecko_params", "(", "request", ",", "days_back", "=", "7", ")", "metric", "=", "Metric", ".", "objects", ".", "get", "(", "uid", "=", "params", "[", "'uid'", "]", ")", "try"...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_rag_widget
Searches the GET variables for metric UIDs, and displays them in a RAG widget.
analytics/geckoboard_views.py
def geckoboard_rag_widget(request): """ Searches the GET variables for metric UIDs, and displays them in a RAG widget. """ params = get_gecko_params(request) print params['uids'] max_date = datetime.now()-timedelta(days=params['days_back']) metrics = Metric.objects.filter(uid__in=param...
def geckoboard_rag_widget(request): """ Searches the GET variables for metric UIDs, and displays them in a RAG widget. """ params = get_gecko_params(request) print params['uids'] max_date = datetime.now()-timedelta(days=params['days_back']) metrics = Metric.objects.filter(uid__in=param...
[ "Searches", "the", "GET", "variables", "for", "metric", "UIDs", "and", "displays", "them", "in", "a", "RAG", "widget", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L112-L126
[ "def", "geckoboard_rag_widget", "(", "request", ")", ":", "params", "=", "get_gecko_params", "(", "request", ")", "print", "params", "[", "'uids'", "]", "max_date", "=", "datetime", ".", "now", "(", ")", "-", "timedelta", "(", "days", "=", "params", "[", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_pie_chart
Shows a pie chart of the metrics in the uids[] GET variable array.
analytics/geckoboard_views.py
def geckoboard_pie_chart(request): """ Shows a pie chart of the metrics in the uids[] GET variable array. """ params = get_gecko_params(request, cumulative=True) from_date = datetime.now()-timedelta(days=params['days_back']) metrics = Metric.objects.filter(uid__in=params['uids']) results =...
def geckoboard_pie_chart(request): """ Shows a pie chart of the metrics in the uids[] GET variable array. """ params = get_gecko_params(request, cumulative=True) from_date = datetime.now()-timedelta(days=params['days_back']) metrics = Metric.objects.filter(uid__in=params['uids']) results =...
[ "Shows", "a", "pie", "chart", "of", "the", "metrics", "in", "the", "uids", "[]", "GET", "variable", "array", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L132-L144
[ "def", "geckoboard_pie_chart", "(", "request", ")", ":", "params", "=", "get_gecko_params", "(", "request", ",", "cumulative", "=", "True", ")", "from_date", "=", "datetime", ".", "now", "(", ")", "-", "timedelta", "(", "days", "=", "params", "[", "'days_b...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_line_chart
Returns the data for a line chart for the specified metric.
analytics/geckoboard_views.py
def geckoboard_line_chart(request): """ Returns the data for a line chart for the specified metric. """ params = get_gecko_params(request, cumulative=False, days_back=7) metric = Metric.objects.get(uid=params['uid']) start_date = datetime.now()-timedelta(days=params['days_back']) stats = [...
def geckoboard_line_chart(request): """ Returns the data for a line chart for the specified metric. """ params = get_gecko_params(request, cumulative=False, days_back=7) metric = Metric.objects.get(uid=params['uid']) start_date = datetime.now()-timedelta(days=params['days_back']) stats = [...
[ "Returns", "the", "data", "for", "a", "line", "chart", "for", "the", "specified", "metric", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L149-L179
[ "def", "geckoboard_line_chart", "(", "request", ")", ":", "params", "=", "get_gecko_params", "(", "request", ",", "cumulative", "=", "False", ",", "days_back", "=", "7", ")", "metric", "=", "Metric", ".", "objects", ".", "get", "(", "uid", "=", "params", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_geckometer
Returns a Geck-o-Meter control for the specified metric.
analytics/geckoboard_views.py
def geckoboard_geckometer(request): """ Returns a Geck-o-Meter control for the specified metric. """ params = get_gecko_params(request, cumulative=True) metric = Metric.objects.get(uid=params['uid']) return (metric.latest_count(frequency=params['frequency'], count=not params['cumulative'], ...
def geckoboard_geckometer(request): """ Returns a Geck-o-Meter control for the specified metric. """ params = get_gecko_params(request, cumulative=True) metric = Metric.objects.get(uid=params['uid']) return (metric.latest_count(frequency=params['frequency'], count=not params['cumulative'], ...
[ "Returns", "a", "Geck", "-", "o", "-", "Meter", "control", "for", "the", "specified", "metric", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L184-L193
[ "def", "geckoboard_geckometer", "(", "request", ")", ":", "params", "=", "get_gecko_params", "(", "request", ",", "cumulative", "=", "True", ")", "metric", "=", "Metric", ".", "objects", ".", "get", "(", "uid", "=", "params", "[", "'uid'", "]", ")", "ret...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
geckoboard_funnel
Returns a funnel chart for the metrics specified in the GET variables.
analytics/geckoboard_views.py
def geckoboard_funnel(request, frequency=settings.STATISTIC_FREQUENCY_DAILY): """ Returns a funnel chart for the metrics specified in the GET variables. """ # get all the parameters for this function params = get_gecko_params(request, cumulative=True) metrics = Metric.objects.filter(uid__in=par...
def geckoboard_funnel(request, frequency=settings.STATISTIC_FREQUENCY_DAILY): """ Returns a funnel chart for the metrics specified in the GET variables. """ # get all the parameters for this function params = get_gecko_params(request, cumulative=True) metrics = Metric.objects.filter(uid__in=par...
[ "Returns", "a", "funnel", "chart", "for", "the", "metrics", "specified", "in", "the", "GET", "variables", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L199-L215
[ "def", "geckoboard_funnel", "(", "request", ",", "frequency", "=", "settings", ".", "STATISTIC_FREQUENCY_DAILY", ")", ":", "# get all the parameters for this function", "params", "=", "get_gecko_params", "(", "request", ",", "cumulative", "=", "True", ")", "metrics", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
AnalyticsView.get_active_stats
Returns all of the active statistics for the gadgets currently registered.
analytics/views.py
def get_active_stats(self): """ Returns all of the active statistics for the gadgets currently registered. """ stats = [] for gadget in self._registry.values(): for s in gadget.stats: if s not in stats: stats.append(s) retur...
def get_active_stats(self): """ Returns all of the active statistics for the gadgets currently registered. """ stats = [] for gadget in self._registry.values(): for s in gadget.stats: if s not in stats: stats.append(s) retur...
[ "Returns", "all", "of", "the", "active", "statistics", "for", "the", "gadgets", "currently", "registered", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/views.py#L22-L31
[ "def", "get_active_stats", "(", "self", ")", ":", "stats", "=", "[", "]", "for", "gadget", "in", "self", ".", "_registry", ".", "values", "(", ")", ":", "for", "s", "in", "gadget", ".", "stats", ":", "if", "s", "not", "in", "stats", ":", "stats", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
AnalyticsView.register
Registers a gadget object. If a gadget is already registered, this will raise AlreadyRegistered.
analytics/views.py
def register(self, gadget): """ Registers a gadget object. If a gadget is already registered, this will raise AlreadyRegistered. """ if gadget in self._registry: raise AlreadyRegistered else: self._registry.append(gadget)
def register(self, gadget): """ Registers a gadget object. If a gadget is already registered, this will raise AlreadyRegistered. """ if gadget in self._registry: raise AlreadyRegistered else: self._registry.append(gadget)
[ "Registers", "a", "gadget", "object", ".", "If", "a", "gadget", "is", "already", "registered", "this", "will", "raise", "AlreadyRegistered", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/views.py#L33-L41
[ "def", "register", "(", "self", ",", "gadget", ")", ":", "if", "gadget", "in", "self", ".", "_registry", ":", "raise", "AlreadyRegistered", "else", ":", "self", ".", "_registry", ".", "append", "(", "gadget", ")" ]
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
AnalyticsView.unregister
Unregisters the specified gadget(s) if it/they has/have already been registered. "gadgets" can be a single class or a tuple/list of classes to unregister.
analytics/views.py
def unregister(self, gadgets): """ Unregisters the specified gadget(s) if it/they has/have already been registered. "gadgets" can be a single class or a tuple/list of classes to unregister. """ gadgets = maintenance.ensure_list(gadgets) for gadget in gadgets: ...
def unregister(self, gadgets): """ Unregisters the specified gadget(s) if it/they has/have already been registered. "gadgets" can be a single class or a tuple/list of classes to unregister. """ gadgets = maintenance.ensure_list(gadgets) for gadget in gadgets: ...
[ "Unregisters", "the", "specified", "gadget", "(", "s", ")", "if", "it", "/", "they", "has", "/", "have", "already", "been", "registered", ".", "gadgets", "can", "be", "a", "single", "class", "or", "a", "tuple", "/", "list", "of", "classes", "to", "unre...
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/views.py#L43-L51
[ "def", "unregister", "(", "self", ",", "gadgets", ")", ":", "gadgets", "=", "maintenance", ".", "ensure_list", "(", "gadgets", ")", "for", "gadget", "in", "gadgets", ":", "while", "gadget", "in", "self", ".", "_registry", ":", "self", ".", "_registry", "...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
AnalyticsView.get_context_data
Get the context for this view.
analytics/views.py
def get_context_data(self, **kwargs): """ Get the context for this view. """ #max_columns, max_rows = self.get_max_dimension() context = { 'gadgets': self._registry, 'columns': self.columns, 'rows': self.rows, 'column_ratio': 100 - ...
def get_context_data(self, **kwargs): """ Get the context for this view. """ #max_columns, max_rows = self.get_max_dimension() context = { 'gadgets': self._registry, 'columns': self.columns, 'rows': self.rows, 'column_ratio': 100 - ...
[ "Get", "the", "context", "for", "this", "view", "." ]
praekelt/django-analytics
python
https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/views.py#L64-L77
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "#max_columns, max_rows = self.get_max_dimension()", "context", "=", "{", "'gadgets'", ":", "self", ".", "_registry", ",", "'columns'", ":", "self", ".", "columns", ",", "'rows'", ":", ...
29c22d03374ccc0ec451650e2c2886d324f6e5c6
test
Command.error
Print error and stop command
publisher/management/commands/publish_model.py
def error(self, message, code=1): """ Print error and stop command """ print >>sys.stderr, message sys.exit(code)
def error(self, message, code=1): """ Print error and stop command """ print >>sys.stderr, message sys.exit(code)
[ "Print", "error", "and", "stop", "command" ]
jp74/django-model-publisher
python
https://github.com/jp74/django-model-publisher/blob/075886b866c9b2232fd7267937c4d7571e251780/publisher/management/commands/publish_model.py#L17-L22
[ "def", "error", "(", "self", ",", "message", ",", "code", "=", "1", ")", ":", "print", ">>", "sys", ".", "stderr", ",", "message", "sys", ".", "exit", "(", "code", ")" ]
075886b866c9b2232fd7267937c4d7571e251780
test
Command.get_model
TODO: Need to validate model name has 2x '.' chars
publisher/management/commands/publish_model.py
def get_model(self, model_name): """ TODO: Need to validate model name has 2x '.' chars """ klass = None try: module_name, class_name = model_name.rsplit('.', 1) mod = __import__(module_name, fromlist=[class_name]) klass = getattr(mod, class_na...
def get_model(self, model_name): """ TODO: Need to validate model name has 2x '.' chars """ klass = None try: module_name, class_name = model_name.rsplit('.', 1) mod = __import__(module_name, fromlist=[class_name]) klass = getattr(mod, class_na...
[ "TODO", ":", "Need", "to", "validate", "model", "name", "has", "2x", ".", "chars" ]
jp74/django-model-publisher
python
https://github.com/jp74/django-model-publisher/blob/075886b866c9b2232fd7267937c4d7571e251780/publisher/management/commands/publish_model.py#L44-L56
[ "def", "get_model", "(", "self", ",", "model_name", ")", ":", "klass", "=", "None", "try", ":", "module_name", ",", "class_name", "=", "model_name", ".", "rsplit", "(", "'.'", ",", "1", ")", "mod", "=", "__import__", "(", "module_name", ",", "fromlist", ...
075886b866c9b2232fd7267937c4d7571e251780
test
JError.custom
Specific server side errors use: -32000 to -32099 reserved for implementation-defined server-errors
aiohttp_jrpc/errors.py
def custom(self, code, message): """ Specific server side errors use: -32000 to -32099 reserved for implementation-defined server-errors """ if -32000 < code or -32099 > code: code = -32603 message = 'Internal error' return JResponse(jsonrpc={ ...
def custom(self, code, message): """ Specific server side errors use: -32000 to -32099 reserved for implementation-defined server-errors """ if -32000 < code or -32099 > code: code = -32603 message = 'Internal error' return JResponse(jsonrpc={ ...
[ "Specific", "server", "side", "errors", "use", ":", "-", "32000", "to", "-", "32099", "reserved", "for", "implementation", "-", "defined", "server", "-", "errors" ]
zloidemon/aiohttp_jrpc
python
https://github.com/zloidemon/aiohttp_jrpc/blob/f2ced214844041aa6f18b6bf6e5abeef7b47735e/aiohttp_jrpc/errors.py#L60-L71
[ "def", "custom", "(", "self", ",", "code", ",", "message", ")", ":", "if", "-", "32000", "<", "code", "or", "-", "32099", ">", "code", ":", "code", "=", "-", "32603", "message", "=", "'Internal error'", "return", "JResponse", "(", "jsonrpc", "=", "{"...
f2ced214844041aa6f18b6bf6e5abeef7b47735e
test
decode
Get/decode/validate json from request
aiohttp_jrpc/__init__.py
def decode(request): """ Get/decode/validate json from request """ try: data = yield from request.json(loader=json.loads) except Exception as err: raise ParseError(err) try: validate(data, REQ_JSONRPC20) except ValidationError as err: raise InvalidRequest(err) ex...
def decode(request): """ Get/decode/validate json from request """ try: data = yield from request.json(loader=json.loads) except Exception as err: raise ParseError(err) try: validate(data, REQ_JSONRPC20) except ValidationError as err: raise InvalidRequest(err) ex...
[ "Get", "/", "decode", "/", "validate", "json", "from", "request" ]
zloidemon/aiohttp_jrpc
python
https://github.com/zloidemon/aiohttp_jrpc/blob/f2ced214844041aa6f18b6bf6e5abeef7b47735e/aiohttp_jrpc/__init__.py#L62-L77
[ "def", "decode", "(", "request", ")", ":", "try", ":", "data", "=", "yield", "from", "request", ".", "json", "(", "loader", "=", "json", ".", "loads", ")", "except", "Exception", "as", "err", ":", "raise", "ParseError", "(", "err", ")", "try", ":", ...
f2ced214844041aa6f18b6bf6e5abeef7b47735e
test
Service.valid
Validation data by specific validictory configuration
aiohttp_jrpc/__init__.py
def valid(schema=None): """ Validation data by specific validictory configuration """ def dec(fun): @wraps(fun) def d_func(self, ctx, data, *a, **kw): try: validate(data['params'], schema) except ValidationError as err: ...
def valid(schema=None): """ Validation data by specific validictory configuration """ def dec(fun): @wraps(fun) def d_func(self, ctx, data, *a, **kw): try: validate(data['params'], schema) except ValidationError as err: ...
[ "Validation", "data", "by", "specific", "validictory", "configuration" ]
zloidemon/aiohttp_jrpc
python
https://github.com/zloidemon/aiohttp_jrpc/blob/f2ced214844041aa6f18b6bf6e5abeef7b47735e/aiohttp_jrpc/__init__.py#L87-L100
[ "def", "valid", "(", "schema", "=", "None", ")", ":", "def", "dec", "(", "fun", ")", ":", "@", "wraps", "(", "fun", ")", "def", "d_func", "(", "self", ",", "ctx", ",", "data", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "try", ":", "valid...
f2ced214844041aa6f18b6bf6e5abeef7b47735e
test
Service.__run
Run service
aiohttp_jrpc/__init__.py
def __run(self, ctx): """ Run service """ try: data = yield from decode(ctx) except ParseError: return JError().parse() except InvalidRequest: return JError().request() except InternalError: return JError().internal() try: ...
def __run(self, ctx): """ Run service """ try: data = yield from decode(ctx) except ParseError: return JError().parse() except InvalidRequest: return JError().request() except InternalError: return JError().internal() try: ...
[ "Run", "service" ]
zloidemon/aiohttp_jrpc
python
https://github.com/zloidemon/aiohttp_jrpc/blob/f2ced214844041aa6f18b6bf6e5abeef7b47735e/aiohttp_jrpc/__init__.py#L103-L129
[ "def", "__run", "(", "self", ",", "ctx", ")", ":", "try", ":", "data", "=", "yield", "from", "decode", "(", "ctx", ")", "except", "ParseError", ":", "return", "JError", "(", ")", ".", "parse", "(", ")", "except", "InvalidRequest", ":", "return", "JEr...
f2ced214844041aa6f18b6bf6e5abeef7b47735e
test
string_input
Python 3 input()/Python 2 raw_input()
lightcli.py
def string_input(prompt=''): """Python 3 input()/Python 2 raw_input()""" v = sys.version[0] if v == '3': return input(prompt) else: return raw_input(prompt)
def string_input(prompt=''): """Python 3 input()/Python 2 raw_input()""" v = sys.version[0] if v == '3': return input(prompt) else: return raw_input(prompt)
[ "Python", "3", "input", "()", "/", "Python", "2", "raw_input", "()" ]
dogoncouch/lightcli
python
https://github.com/dogoncouch/lightcli/blob/e63093dfc4f983ec9c9571ff186bf114c1f782c3/lightcli.py#L35-L41
[ "def", "string_input", "(", "prompt", "=", "''", ")", ":", "v", "=", "sys", ".", "version", "[", "0", "]", "if", "v", "==", "'3'", ":", "return", "input", "(", "prompt", ")", "else", ":", "return", "raw_input", "(", "prompt", ")" ]
e63093dfc4f983ec9c9571ff186bf114c1f782c3
test
choice_input
Get input from a list of choices (q to quit)
lightcli.py
def choice_input(options=[], prompt='Press ENTER to continue.', showopts=True, qopt=False): """Get input from a list of choices (q to quit)""" choice = None if showopts: prompt = prompt + ' ' + str(options) if qopt: prompt = prompt + ' (q to quit)' while not choice: ...
def choice_input(options=[], prompt='Press ENTER to continue.', showopts=True, qopt=False): """Get input from a list of choices (q to quit)""" choice = None if showopts: prompt = prompt + ' ' + str(options) if qopt: prompt = prompt + ' (q to quit)' while not choice: ...
[ "Get", "input", "from", "a", "list", "of", "choices", "(", "q", "to", "quit", ")" ]
dogoncouch/lightcli
python
https://github.com/dogoncouch/lightcli/blob/e63093dfc4f983ec9c9571ff186bf114c1f782c3/lightcli.py#L44-L79
[ "def", "choice_input", "(", "options", "=", "[", "]", ",", "prompt", "=", "'Press ENTER to continue.'", ",", "showopts", "=", "True", ",", "qopt", "=", "False", ")", ":", "choice", "=", "None", "if", "showopts", ":", "prompt", "=", "prompt", "+", "' '", ...
e63093dfc4f983ec9c9571ff186bf114c1f782c3
test
long_input
Get a multi-line string as input
lightcli.py
def long_input(prompt='Multi-line input\n' + \ 'Enter EOF on a blank line to end ' + \ '(ctrl-D in *nix, ctrl-Z in windows)', maxlines = None, maxlength = None): """Get a multi-line string as input""" lines = [] print(prompt) lnum = 1 try: while True: ...
def long_input(prompt='Multi-line input\n' + \ 'Enter EOF on a blank line to end ' + \ '(ctrl-D in *nix, ctrl-Z in windows)', maxlines = None, maxlength = None): """Get a multi-line string as input""" lines = [] print(prompt) lnum = 1 try: while True: ...
[ "Get", "a", "multi", "-", "line", "string", "as", "input" ]
dogoncouch/lightcli
python
https://github.com/dogoncouch/lightcli/blob/e63093dfc4f983ec9c9571ff186bf114c1f782c3/lightcli.py#L83-L117
[ "def", "long_input", "(", "prompt", "=", "'Multi-line input\\n'", "+", "'Enter EOF on a blank line to end '", "+", "'(ctrl-D in *nix, ctrl-Z in windows)'", ",", "maxlines", "=", "None", ",", "maxlength", "=", "None", ")", ":", "lines", "=", "[", "]", "print", "(", ...
e63093dfc4f983ec9c9571ff186bf114c1f782c3
test
list_input
Get a list of strings as input
lightcli.py
def list_input(prompt='List input - enter each item on a seperate line\n' + \ 'Enter EOF on a blank line to end ' + \ '(ctrl-D in *nix, ctrl-Z in windows)', maxitems=None, maxlength=None): """Get a list of strings as input""" lines = [] print(prompt) inum = 1 try: ...
def list_input(prompt='List input - enter each item on a seperate line\n' + \ 'Enter EOF on a blank line to end ' + \ '(ctrl-D in *nix, ctrl-Z in windows)', maxitems=None, maxlength=None): """Get a list of strings as input""" lines = [] print(prompt) inum = 1 try: ...
[ "Get", "a", "list", "of", "strings", "as", "input" ]
dogoncouch/lightcli
python
https://github.com/dogoncouch/lightcli/blob/e63093dfc4f983ec9c9571ff186bf114c1f782c3/lightcli.py#L121-L155
[ "def", "list_input", "(", "prompt", "=", "'List input - enter each item on a seperate line\\n'", "+", "'Enter EOF on a blank line to end '", "+", "'(ctrl-D in *nix, ctrl-Z in windows)'", ",", "maxitems", "=", "None", ",", "maxlength", "=", "None", ")", ":", "lines", "=", ...
e63093dfc4f983ec9c9571ff186bf114c1f782c3
test
outfile_input
Get an output file name as input
lightcli.py
def outfile_input(extension=None): """Get an output file name as input""" fileok = False while not fileok: filename = string_input('File name? ') if extension: if not filename.endswith(extension): if extension.startswith('.'): filenam...
def outfile_input(extension=None): """Get an output file name as input""" fileok = False while not fileok: filename = string_input('File name? ') if extension: if not filename.endswith(extension): if extension.startswith('.'): filenam...
[ "Get", "an", "output", "file", "name", "as", "input" ]
dogoncouch/lightcli
python
https://github.com/dogoncouch/lightcli/blob/e63093dfc4f983ec9c9571ff186bf114c1f782c3/lightcli.py#L158-L209
[ "def", "outfile_input", "(", "extension", "=", "None", ")", ":", "fileok", "=", "False", "while", "not", "fileok", ":", "filename", "=", "string_input", "(", "'File name? '", ")", "if", "extension", ":", "if", "not", "filename", ".", "endswith", "(", "exte...
e63093dfc4f983ec9c9571ff186bf114c1f782c3
test
Team.roster
Returns the roster table for the given year. :year: The year for which we want the roster; defaults to current year. :returns: A DataFrame containing roster information for that year.
sportsref/nba/teams.py
def roster(self, year): """Returns the roster table for the given year. :year: The year for which we want the roster; defaults to current year. :returns: A DataFrame containing roster information for that year. """ doc = self.get_year_doc(year) table = doc('table#roster'...
def roster(self, year): """Returns the roster table for the given year. :year: The year for which we want the roster; defaults to current year. :returns: A DataFrame containing roster information for that year. """ doc = self.get_year_doc(year) table = doc('table#roster'...
[ "Returns", "the", "roster", "table", "for", "the", "given", "year", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/teams.py#L52-L63
[ "def", "roster", "(", "self", ",", "year", ")", ":", "doc", "=", "self", ".", "get_year_doc", "(", "year", ")", "table", "=", "doc", "(", "'table#roster'", ")", "df", "=", "sportsref", ".", "utils", ".", "parse_table", "(", "table", ")", "df", "[", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Team.schedule
Gets schedule information for a team-season. :year: The year for which we want the schedule. :returns: DataFrame of schedule information.
sportsref/nba/teams.py
def schedule(self, year): """Gets schedule information for a team-season. :year: The year for which we want the schedule. :returns: DataFrame of schedule information. """ doc = self.get_year_doc('{}_games'.format(year)) table = doc('table#games') df = sportsref.u...
def schedule(self, year): """Gets schedule information for a team-season. :year: The year for which we want the schedule. :returns: DataFrame of schedule information. """ doc = self.get_year_doc('{}_games'.format(year)) table = doc('table#games') df = sportsref.u...
[ "Gets", "schedule", "information", "for", "a", "team", "-", "season", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/teams.py#L67-L76
[ "def", "schedule", "(", "self", ",", "year", ")", ":", "doc", "=", "self", ".", "get_year_doc", "(", "'{}_games'", ".", "format", "(", "year", ")", ")", "table", "=", "doc", "(", "'table#games'", ")", "df", "=", "sportsref", ".", "utils", ".", "parse...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.date
Returns the date of the game. See Python datetime.date documentation for more. :returns: A datetime.date object with year, month, and day attributes.
sportsref/nfl/boxscores.py
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 = map(int, match.grou...
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 = map(int, match.grou...
[ "Returns", "the", "date", "of", "the", "game", ".", "See", "Python", "datetime", ".", "date", "documentation", "for", "more", ".", ":", "returns", ":", "A", "datetime", ".", "date", "object", "with", "year", "month", "and", "day", "attributes", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L51-L58
[ "def", "date", "(", "self", ")", ":", "match", "=", "re", ".", "match", "(", "r'(\\d{4})(\\d{2})(\\d{2})'", ",", "self", ".", "boxscore_id", ")", "year", ",", "month", ",", "day", "=", "map", "(", "int", ",", "match", ".", "groups", "(", ")", ")", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.weekday
Returns the day of the week on which the game occurred. :returns: String representation of the day of the week for the game.
sportsref/nfl/boxscores.py
def weekday(self): """Returns the day of the week on which the game occurred. :returns: String representation of the day of the week for the game. """ days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] date = self.date() ...
def weekday(self): """Returns the day of the week on which the game occurred. :returns: String representation of the day of the week for the game. """ days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] date = self.date() ...
[ "Returns", "the", "day", "of", "the", "week", "on", "which", "the", "game", "occurred", ".", ":", "returns", ":", "String", "representation", "of", "the", "day", "of", "the", "week", "for", "the", "game", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L61-L70
[ "def", "weekday", "(", "self", ")", ":", "days", "=", "[", "'Monday'", ",", "'Tuesday'", ",", "'Wednesday'", ",", "'Thursday'", ",", "'Friday'", ",", "'Saturday'", ",", "'Sunday'", "]", "date", "=", "self", ".", "date", "(", ")", "wd", "=", "date", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.home
Returns home team ID. :returns: 3-character string representing home team's ID.
sportsref/nfl/boxscores.py
def home(self): """Returns home team ID. :returns: 3-character string representing home team's ID. """ doc = self.get_doc() table = doc('table.linescore') relURL = table('tr').eq(2)('a').eq(2).attr['href'] home = sportsref.utils.rel_url_to_id(relURL) retur...
def home(self): """Returns home team ID. :returns: 3-character string representing home team's ID. """ doc = self.get_doc() table = doc('table.linescore') relURL = table('tr').eq(2)('a').eq(2).attr['href'] home = sportsref.utils.rel_url_to_id(relURL) retur...
[ "Returns", "home", "team", "ID", ".", ":", "returns", ":", "3", "-", "character", "string", "representing", "home", "team", "s", "ID", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L73-L81
[ "def", "home", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table.linescore'", ")", "relURL", "=", "table", "(", "'tr'", ")", ".", "eq", "(", "2", ")", "(", "'a'", ")", ".", "eq", "(", "2", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.home_score
Returns score of the home team. :returns: int of the home score.
sportsref/nfl/boxscores.py
def home_score(self): """Returns score of the home team. :returns: int of the home score. """ doc = self.get_doc() table = doc('table.linescore') home_score = table('tr').eq(2)('td')[-1].text_content() return int(home_score)
def home_score(self): """Returns score of the home team. :returns: int of the home score. """ doc = self.get_doc() table = doc('table.linescore') home_score = table('tr').eq(2)('td')[-1].text_content() return int(home_score)
[ "Returns", "score", "of", "the", "home", "team", ".", ":", "returns", ":", "int", "of", "the", "home", "score", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L95-L102
[ "def", "home_score", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table.linescore'", ")", "home_score", "=", "table", "(", "'tr'", ")", ".", "eq", "(", "2", ")", "(", "'td'", ")", "[", "-", "1",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.away_score
Returns score of the away team. :returns: int of the away score.
sportsref/nfl/boxscores.py
def away_score(self): """Returns score of the away team. :returns: int of the away score. """ doc = self.get_doc() table = doc('table.linescore') away_score = table('tr').eq(1)('td')[-1].text_content() return int(away_score)
def away_score(self): """Returns score of the away team. :returns: int of the away score. """ doc = self.get_doc() table = doc('table.linescore') away_score = table('tr').eq(1)('td')[-1].text_content() return int(away_score)
[ "Returns", "score", "of", "the", "away", "team", ".", ":", "returns", ":", "int", "of", "the", "away", "score", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L105-L112
[ "def", "away_score", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table.linescore'", ")", "away_score", "=", "table", "(", "'tr'", ")", ".", "eq", "(", "1", ")", "(", "'td'", ")", "[", "-", "1",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.winner
Returns the team ID of the winning team. Returns NaN if a tie.
sportsref/nfl/boxscores.py
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: ret...
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: ret...
[ "Returns", "the", "team", "ID", "of", "the", "winning", "team", ".", "Returns", "NaN", "if", "a", "tie", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L115-L124
[ "def", "winner", "(", "self", ")", ":", "hmScore", "=", "self", ".", "home_score", "(", ")", "awScore", "=", "self", ".", "away_score", "(", ")", "if", "hmScore", ">", "awScore", ":", "return", "self", ".", "home", "(", ")", "elif", "hmScore", "<", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.week
Returns the week in which this game took place. 18 is WC round, 19 is Div round, 20 is CC round, 21 is SB. :returns: Integer from 1 to 21.
sportsref/nfl/boxscores.py
def week(self): """Returns the week in which this game took place. 18 is WC round, 19 is Div round, 20 is CC round, 21 is SB. :returns: Integer from 1 to 21. """ doc = self.get_doc() raw = doc('div#div_other_scores h2 a').attr['href'] match = re.match( ...
def week(self): """Returns the week in which this game took place. 18 is WC round, 19 is Div round, 20 is CC round, 21 is SB. :returns: Integer from 1 to 21. """ doc = self.get_doc() raw = doc('div#div_other_scores h2 a').attr['href'] match = re.match( ...
[ "Returns", "the", "week", "in", "which", "this", "game", "took", "place", ".", "18", "is", "WC", "round", "19", "is", "Div", "round", "20", "is", "CC", "round", "21", "is", "SB", ".", ":", "returns", ":", "Integer", "from", "1", "to", "21", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L127-L140
[ "def", "week", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "raw", "=", "doc", "(", "'div#div_other_scores h2 a'", ")", ".", "attr", "[", "'href'", "]", "match", "=", "re", ".", "match", "(", "r'/years/{}/week_(\\d+)\\.htm'", ".",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.season
Returns the year ID of the season in which this game took place. Useful for week 17 January games. :returns: An int representing the year of the season.
sportsref/nfl/boxscores.py
def season(self): """ Returns the year ID of the season in which this game took place. Useful for week 17 January games. :returns: An int representing the year of the season. """ date = self.date() return date.year - 1 if date.month <= 3 else date.year
def season(self): """ Returns the year ID of the season in which this game took place. Useful for week 17 January games. :returns: An int representing the year of the season. """ date = self.date() return date.year - 1 if date.month <= 3 else date.year
[ "Returns", "the", "year", "ID", "of", "the", "season", "in", "which", "this", "game", "took", "place", ".", "Useful", "for", "week", "17", "January", "games", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L143-L151
[ "def", "season", "(", "self", ")", ":", "date", "=", "self", ".", "date", "(", ")", "return", "date", ".", "year", "-", "1", "if", "date", ".", "month", "<=", "3", "else", "date", ".", "year" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.starters
Returns a DataFrame where each row is an entry in the starters table from PFR. The columns are: * player_id - the PFR player ID for the player (note that this column is not necessarily all unique; that is, one player can be a starter in multiple positions, in theory). * ...
sportsref/nfl/boxscores.py
def starters(self): """Returns a DataFrame where each row is an entry in the starters table from PFR. The columns are: * player_id - the PFR player ID for the player (note that this column is not necessarily all unique; that is, one player can be a starter in multiple po...
def starters(self): """Returns a DataFrame where each row is an entry in the starters table from PFR. The columns are: * player_id - the PFR player ID for the player (note that this column is not necessarily all unique; that is, one player can be a starter in multiple po...
[ "Returns", "a", "DataFrame", "where", "each", "row", "is", "an", "entry", "in", "the", "starters", "table", "from", "PFR", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L154-L189
[ "def", "starters", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "a", "=", "doc", "(", "'table#vis_starters'", ")", "h", "=", "doc", "(", "'table#home_starters'", ")", "data", "=", "[", "]", "for", "h", ",", "table", "in", "e...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.surface
The playing surface on which the game was played. :returns: string representing the type of surface. Returns np.nan if not avaiable.
sportsref/nfl/boxscores.py
def surface(self): """The playing surface on which the game was played. :returns: string representing the type of surface. Returns np.nan if not avaiable. """ doc = self.get_doc() table = doc('table#game_info') giTable = sportsref.utils.parse_info_table(table) ...
def surface(self): """The playing surface on which the game was played. :returns: string representing the type of surface. Returns np.nan if not avaiable. """ doc = self.get_doc() table = doc('table#game_info') giTable = sportsref.utils.parse_info_table(table) ...
[ "The", "playing", "surface", "on", "which", "the", "game", "was", "played", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L212-L221
[ "def", "surface", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#game_info'", ")", "giTable", "=", "sportsref", ".", "utils", ".", "parse_info_table", "(", "table", ")", "return", "giTable", ".", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.over_under
Returns the over/under for the game as a float, or np.nan if not available.
sportsref/nfl/boxscores.py
def over_under(self): """ Returns the over/under for the game as a float, or np.nan if not available. """ doc = self.get_doc() table = doc('table#game_info') giTable = sportsref.utils.parse_info_table(table) if 'over_under' in giTable: ou = giT...
def over_under(self): """ Returns the over/under for the game as a float, or np.nan if not available. """ doc = self.get_doc() table = doc('table#game_info') giTable = sportsref.utils.parse_info_table(table) if 'over_under' in giTable: ou = giT...
[ "Returns", "the", "over", "/", "under", "for", "the", "game", "as", "a", "float", "or", "np", ".", "nan", "if", "not", "available", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L224-L236
[ "def", "over_under", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#game_info'", ")", "giTable", "=", "sportsref", ".", "utils", ".", "parse_info_table", "(", "table", ")", "if", "'over_under'", "in...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.coin_toss
Gets information relating to the opening coin toss. Keys are: * wonToss - contains the ID of the team that won the toss * deferred - bool whether the team that won the toss deferred it :returns: Dictionary of coin toss-related info.
sportsref/nfl/boxscores.py
def coin_toss(self): """Gets information relating to the opening coin toss. Keys are: * wonToss - contains the ID of the team that won the toss * deferred - bool whether the team that won the toss deferred it :returns: Dictionary of coin toss-related info. """ d...
def coin_toss(self): """Gets information relating to the opening coin toss. Keys are: * wonToss - contains the ID of the team that won the toss * deferred - bool whether the team that won the toss deferred it :returns: Dictionary of coin toss-related info. """ d...
[ "Gets", "information", "relating", "to", "the", "opening", "coin", "toss", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L239-L255
[ "def", "coin_toss", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#game_info'", ")", "giTable", "=", "sportsref", ".", "utils", ".", "parse_info_table", "(", "table", ")", "if", "'Won Toss'", "in", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.weather
Returns a dictionary of weather-related info. Keys of the returned dict: * temp * windChill * relHumidity * windMPH :returns: Dict of weather data.
sportsref/nfl/boxscores.py
def weather(self): """Returns a dictionary of weather-related info. Keys of the returned dict: * temp * windChill * relHumidity * windMPH :returns: Dict of weather data. """ doc = self.get_doc() table = doc('table#game_info') giTa...
def weather(self): """Returns a dictionary of weather-related info. Keys of the returned dict: * temp * windChill * relHumidity * windMPH :returns: Dict of weather data. """ doc = self.get_doc() table = doc('table#game_info') giTa...
[ "Returns", "a", "dictionary", "of", "weather", "-", "related", "info", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L258-L299
[ "def", "weather", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#game_info'", ")", "giTable", "=", "sportsref", ".", "utils", ".", "parse_info_table", "(", "table", ")", "if", "'weather'", "in", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.pbp
Returns a dataframe of the play-by-play data from the game. Order of function calls: 1. parse_table on the play-by-play table 2. expand_details - calls parse_play_details & _clean_features 3. _add_team_columns 4. various fixes to clean data ...
sportsref/nfl/boxscores.py
def pbp(self): """Returns a dataframe of the play-by-play data from the game. Order of function calls: 1. parse_table on the play-by-play table 2. expand_details - calls parse_play_details & _clean_features 3. _add_team_columns 4. various ...
def pbp(self): """Returns a dataframe of the play-by-play data from the game. Order of function calls: 1. parse_table on the play-by-play table 2. expand_details - calls parse_play_details & _clean_features 3. _add_team_columns 4. various ...
[ "Returns", "a", "dataframe", "of", "the", "play", "-", "by", "-", "play", "data", "from", "the", "game", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L302-L367
[ "def", "pbp", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#pbp'", ")", "df", "=", "sportsref", ".", "utils", ".", "parse_table", "(", "table", ")", "# make the following features conveniently availabl...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.ref_info
Gets a dictionary of ref positions and the ref IDs of the refs for that game. :returns: A dictionary of ref positions and IDs.
sportsref/nfl/boxscores.py
def ref_info(self): """Gets a dictionary of ref positions and the ref IDs of the refs for that game. :returns: A dictionary of ref positions and IDs. """ doc = self.get_doc() table = doc('table#officials') return sportsref.utils.parse_info_table(table)
def ref_info(self): """Gets a dictionary of ref positions and the ref IDs of the refs for that game. :returns: A dictionary of ref positions and IDs. """ doc = self.get_doc() table = doc('table#officials') return sportsref.utils.parse_info_table(table)
[ "Gets", "a", "dictionary", "of", "ref", "positions", "and", "the", "ref", "IDs", "of", "the", "refs", "for", "that", "game", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L370-L378
[ "def", "ref_info", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "doc", "(", "'table#officials'", ")", "return", "sportsref", ".", "utils", ".", "parse_info_table", "(", "table", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.player_stats
Gets the stats for offense, defense, returning, and kicking of individual players in the game. :returns: A DataFrame containing individual player stats.
sportsref/nfl/boxscores.py
def player_stats(self): """Gets the stats for offense, defense, returning, and kicking of individual players in the game. :returns: A DataFrame containing individual player stats. """ doc = self.get_doc() tableIDs = ('player_offense', 'player_defense', 'returns', 'kicking...
def player_stats(self): """Gets the stats for offense, defense, returning, and kicking of individual players in the game. :returns: A DataFrame containing individual player stats. """ doc = self.get_doc() tableIDs = ('player_offense', 'player_defense', 'returns', 'kicking...
[ "Gets", "the", "stats", "for", "offense", "defense", "returning", "and", "kicking", "of", "individual", "players", "in", "the", "game", ".", ":", "returns", ":", "A", "DataFrame", "containing", "individual", "player", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L381-L398
[ "def", "player_stats", "(", "self", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "tableIDs", "=", "(", "'player_offense'", ",", "'player_defense'", ",", "'returns'", ",", "'kicking'", ")", "dfs", "=", "[", "]", "for", "tID", "in", "tableIDs", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.snap_counts
Gets the snap counts for both teams' players and returns them in a DataFrame. Note: only goes back to 2012. :returns: DataFrame of snap count data
sportsref/nfl/boxscores.py
def snap_counts(self): """Gets the snap counts for both teams' players and returns them in a DataFrame. Note: only goes back to 2012. :returns: DataFrame of snap count data """ # TODO: combine duplicate players, see 201312150mia - ThomDa03 doc = self.get_doc() ta...
def snap_counts(self): """Gets the snap counts for both teams' players and returns them in a DataFrame. Note: only goes back to 2012. :returns: DataFrame of snap count data """ # TODO: combine duplicate players, see 201312150mia - ThomDa03 doc = self.get_doc() ta...
[ "Gets", "the", "snap", "counts", "for", "both", "teams", "players", "and", "returns", "them", "in", "a", "DataFrame", ".", "Note", ":", "only", "goes", "back", "to", "2012", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L401-L418
[ "def", "snap_counts", "(", "self", ")", ":", "# TODO: combine duplicate players, see 201312150mia - ThomDa03", "doc", "=", "self", ".", "get_doc", "(", ")", "table_ids", "=", "(", "'vis_snap_counts'", ",", "'home_snap_counts'", ")", "tms", "=", "(", "self", ".", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.get_main_doc
Returns PyQuery object for the main season URL. :returns: PyQuery object.
sportsref/nba/seasons.py
def get_main_doc(self): """Returns PyQuery object for the main season URL. :returns: PyQuery object. """ url = (sportsref.nba.BASE_URL + '/leagues/NBA_{}.html'.format(self.yr)) return pq(sportsref.utils.get_html(url))
def get_main_doc(self): """Returns PyQuery object for the main season URL. :returns: PyQuery object. """ url = (sportsref.nba.BASE_URL + '/leagues/NBA_{}.html'.format(self.yr)) return pq(sportsref.utils.get_html(url))
[ "Returns", "PyQuery", "object", "for", "the", "main", "season", "URL", ".", ":", "returns", ":", "PyQuery", "object", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L44-L50
[ "def", "get_main_doc", "(", "self", ")", ":", "url", "=", "(", "sportsref", ".", "nba", ".", "BASE_URL", "+", "'/leagues/NBA_{}.html'", ".", "format", "(", "self", ".", "yr", ")", ")", "return", "pq", "(", "sportsref", ".", "utils", ".", "get_html", "(...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.get_sub_doc
Returns PyQuery object for a given subpage URL. :subpage: The subpage of the season, e.g. 'per_game'. :returns: PyQuery object.
sportsref/nba/seasons.py
def get_sub_doc(self, subpage): """Returns PyQuery object for a given subpage URL. :subpage: The subpage of the season, e.g. 'per_game'. :returns: PyQuery object. """ html = sportsref.utils.get_html(self._subpage_url(subpage)) return pq(html)
def get_sub_doc(self, subpage): """Returns PyQuery object for a given subpage URL. :subpage: The subpage of the season, e.g. 'per_game'. :returns: PyQuery object. """ html = sportsref.utils.get_html(self._subpage_url(subpage)) return pq(html)
[ "Returns", "PyQuery", "object", "for", "a", "given", "subpage", "URL", ".", ":", "subpage", ":", "The", "subpage", "of", "the", "season", "e", ".", "g", ".", "per_game", ".", ":", "returns", ":", "PyQuery", "object", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L53-L59
[ "def", "get_sub_doc", "(", "self", ",", "subpage", ")", ":", "html", "=", "sportsref", ".", "utils", ".", "get_html", "(", "self", ".", "_subpage_url", "(", "subpage", ")", ")", "return", "pq", "(", "html", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.get_team_ids
Returns a list of the team IDs for the given year. :returns: List of team IDs.
sportsref/nba/seasons.py
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 []
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 []
[ "Returns", "a", "list", "of", "the", "team", "IDs", "for", "the", "given", "year", ".", ":", "returns", ":", "List", "of", "team", "IDs", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L62-L71
[ "def", "get_team_ids", "(", "self", ")", ":", "df", "=", "self", ".", "team_stats_per_game", "(", ")", "if", "not", "df", ".", "empty", ":", "return", "df", ".", "index", ".", "tolist", "(", ")", "else", ":", "print", "(", "'ERROR: no teams found'", ")...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.team_ids_to_names
Mapping from 3-letter team IDs to full team names. :returns: Dictionary with team IDs as keys and full team strings as values.
sportsref/nba/seasons.py
def team_ids_to_names(self): """Mapping from 3-letter 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') flattened = sportsref.utils.parse_...
def team_ids_to_names(self): """Mapping from 3-letter 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') flattened = sportsref.utils.parse_...
[ "Mapping", "from", "3", "-", "letter", "team", "IDs", "to", "full", "team", "names", ".", ":", "returns", ":", "Dictionary", "with", "team", "IDs", "as", "keys", "and", "full", "team", "strings", "as", "values", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L74-L87
[ "def", "team_ids_to_names", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "table", "=", "doc", "(", "'table#team-stats-per_game'", ")", "flattened", "=", "sportsref", ".", "utils", ".", "parse_table", "(", "table", ",", "flatten",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.team_names_to_ids
Mapping from full team names to 3-letter team IDs. :returns: Dictionary with tean names as keys and team IDs as values.
sportsref/nba/seasons.py
def team_names_to_ids(self): """Mapping from full team names to 3-letter 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 d.items()}
def team_names_to_ids(self): """Mapping from full team names to 3-letter 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 d.items()}
[ "Mapping", "from", "full", "team", "names", "to", "3", "-", "letter", "team", "IDs", ".", ":", "returns", ":", "Dictionary", "with", "tean", "names", "as", "keys", "and", "team", "IDs", "as", "values", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L90-L95
[ "def", "team_names_to_ids", "(", "self", ")", ":", "d", "=", "self", ".", "team_ids_to_names", "(", ")", "return", "{", "v", ":", "k", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", "}" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.schedule
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, 'P' for playoffs, 'B' for both. Defaults to 'R'. :returns: DataFrame of schedule information. :rtype: pd.D...
sportsref/nba/seasons.py
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, 'P' for playoffs, 'B' for both. Defaults to 'R'. :returns: DataFrame of s...
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, 'P' for playoffs, 'B' for both. Defaults to 'R'. :returns: DataFrame of s...
[ "Returns", "a", "list", "of", "BoxScore", "IDs", "for", "every", "game", "in", "the", "season", ".", "Only", "needs", "to", "handle", "R", "or", "P", "options", "because", "decorator", "handles", "B", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L99-L142
[ "def", "schedule", "(", "self", ",", "kind", "=", "'R'", ")", ":", "kind", "=", "kind", ".", "upper", "(", ")", "[", "0", "]", "dfs", "=", "[", "]", "# get games from each month", "for", "month", "in", "(", "'october'", ",", "'november'", ",", "'dece...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.standings
Returns a DataFrame containing standings information.
sportsref/nba/seasons.py
def standings(self): """Returns a DataFrame containing standings information.""" doc = self.get_sub_doc('standings') east_table = doc('table#divs_standings_E') east_df = pd.DataFrame(sportsref.utils.parse_table(east_table)) east_df.sort_values('wins', ascending=False, inplace=Tr...
def standings(self): """Returns a DataFrame containing standings information.""" doc = self.get_sub_doc('standings') east_table = doc('table#divs_standings_E') east_df = pd.DataFrame(sportsref.utils.parse_table(east_table)) east_df.sort_values('wins', ascending=False, inplace=Tr...
[ "Returns", "a", "DataFrame", "containing", "standings", "information", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L156-L182
[ "def", "standings", "(", "self", ")", ":", "doc", "=", "self", ".", "get_sub_doc", "(", "'standings'", ")", "east_table", "=", "doc", "(", "'table#divs_standings_E'", ")", "east_df", "=", "pd", ".", "DataFrame", "(", "sportsref", ".", "utils", ".", "parse_...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season._get_team_stats_table
Helper function for stats tables on season pages. Returns a DataFrame.
sportsref/nba/seasons.py
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.set_index('team_id', inplace=True) return df
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.set_index('team_id', inplace=True) return df
[ "Helper", "function", "for", "stats", "tables", "on", "season", "pages", ".", "Returns", "a", "DataFrame", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L185-L192
[ "def", "_get_team_stats_table", "(", "self", ",", "selector", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "table", "=", "doc", "(", "selector", ")", "df", "=", "sportsref", ".", "utils", ".", "parse_table", "(", "table", ")", "df", "."...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season._get_player_stats_table
Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'per_game'. :returns: A DataFrame of stats.
sportsref/nba/seasons.py
def _get_player_stats_table(self, identifier): """Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'per_game'. :returns: A DataFrame of stats. """ doc = self.get_sub_doc(identifier) table = doc('table#{}_stats'.format(identi...
def _get_player_stats_table(self, identifier): """Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'per_game'. :returns: A DataFrame of stats. """ doc = self.get_sub_doc(identifier) table = doc('table#{}_stats'.format(identi...
[ "Helper", "function", "for", "player", "season", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L230-L239
[ "def", "_get_player_stats_table", "(", "self", ",", "identifier", ")", ":", "doc", "=", "self", ".", "get_sub_doc", "(", "identifier", ")", "table", "=", "doc", "(", "'table#{}_stats'", ".", "format", "(", "identifier", ")", ")", "df", "=", "sportsref", "....
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season.roy_voting
Returns a DataFrame containing information about ROY voting.
sportsref/nba/seasons.py
def roy_voting(self): """Returns a DataFrame containing information about ROY voting.""" url = '{}/awards/awards_{}.html'.format(sportsref.nba.BASE_URL, self.yr) doc = pq(sportsref.utils.get_html(url)) table = doc('table#roy') df = sportsref.utils.parse_table(table) retur...
def roy_voting(self): """Returns a DataFrame containing information about ROY voting.""" url = '{}/awards/awards_{}.html'.format(sportsref.nba.BASE_URL, self.yr) doc = pq(sportsref.utils.get_html(url)) table = doc('table#roy') df = sportsref.utils.parse_table(table) retur...
[ "Returns", "a", "DataFrame", "containing", "information", "about", "ROY", "voting", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L265-L271
[ "def", "roy_voting", "(", "self", ")", ":", "url", "=", "'{}/awards/awards_{}.html'", ".", "format", "(", "sportsref", ".", "nba", ".", "BASE_URL", ",", "self", ".", "yr", ")", "doc", "=", "pq", "(", "sportsref", ".", "utils", ".", "get_html", "(", "ur...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.linescore
Returns the linescore for the game as a DataFrame.
sportsref/nba/boxscores.py
def linescore(self): """Returns the linescore for the game as a DataFrame.""" doc = self.get_main_doc() table = doc('table#line_score') columns = [th.text() for th in table('tr.thead').items('th')] columns[0] = 'team_id' data = [ [sportsref.utils.flatten_lin...
def linescore(self): """Returns the linescore for the game as a DataFrame.""" doc = self.get_main_doc() table = doc('table#line_score') columns = [th.text() for th in table('tr.thead').items('th')] columns[0] = 'team_id' data = [ [sportsref.utils.flatten_lin...
[ "Returns", "the", "linescore", "for", "the", "game", "as", "a", "DataFrame", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/boxscores.py#L65-L79
[ "def", "linescore", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "table", "=", "doc", "(", "'table#line_score'", ")", "columns", "=", "[", "th", ".", "text", "(", ")", "for", "th", "in", "table", "(", "'tr.thead'", ")", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.season
Returns the year ID of the season in which this game took place. :returns: An int representing the year of the season.
sportsref/nba/boxscores.py
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. """ d = self.date() if d.month >= 9: return d.year + 1 else: return d.year
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. """ d = self.date() if d.month >= 9: return d.year + 1 else: return d.year
[ "Returns", "the", "year", "ID", "of", "the", "season", "in", "which", "this", "game", "took", "place", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/boxscores.py#L126-L136
[ "def", "season", "(", "self", ")", ":", "d", "=", "self", ".", "date", "(", ")", "if", "d", ".", "month", ">=", "9", ":", "return", "d", ".", "year", "+", "1", "else", ":", "return", "d", ".", "year" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore._get_player_stats
Returns a DataFrame of player stats from the game (either basic or advanced, depending on the argument. :param table_id_fmt: Format string for str.format with a placeholder for the team ID (e.g. 'box_{}_basic') :returns: DataFrame of player stats
sportsref/nba/boxscores.py
def _get_player_stats(self, table_id_fmt): """Returns a DataFrame of player stats from the game (either basic or advanced, depending on the argument. :param table_id_fmt: Format string for str.format with a placeholder for the team ID (e.g. 'box_{}_basic') :returns: DataFram...
def _get_player_stats(self, table_id_fmt): """Returns a DataFrame of player stats from the game (either basic or advanced, depending on the argument. :param table_id_fmt: Format string for str.format with a placeholder for the team ID (e.g. 'box_{}_basic') :returns: DataFram...
[ "Returns", "a", "DataFrame", "of", "player", "stats", "from", "the", "game", "(", "either", "basic", "or", "advanced", "depending", "on", "the", "argument", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/boxscores.py#L138-L165
[ "def", "_get_player_stats", "(", "self", ",", "table_id_fmt", ")", ":", "# get data", "doc", "=", "self", ".", "get_main_doc", "(", ")", "tms", "=", "self", ".", "away", "(", ")", ",", "self", ".", "home", "(", ")", "tm_ids", "=", "[", "table_id_fmt", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
BoxScore.pbp
Returns a dataframe of the play-by-play data from the game. :param dense_lineups: If True, adds 10 columns containing the names of the players on the court. Defaults to False. :param sparse_lineups: If True, adds binary columns denoting whether a given player is in the game at t...
sportsref/nba/boxscores.py
def pbp(self, dense_lineups=False, sparse_lineups=False): """Returns a dataframe of the play-by-play data from the game. :param dense_lineups: If True, adds 10 columns containing the names of the players on the court. Defaults to False. :param sparse_lineups: If True, adds binary co...
def pbp(self, dense_lineups=False, sparse_lineups=False): """Returns a dataframe of the play-by-play data from the game. :param dense_lineups: If True, adds 10 columns containing the names of the players on the court. Defaults to False. :param sparse_lineups: If True, adds binary co...
[ "Returns", "a", "dataframe", "of", "the", "play", "-", "by", "-", "play", "data", "from", "the", "game", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/boxscores.py#L178-L460
[ "def", "pbp", "(", "self", ",", "dense_lineups", "=", "False", ",", "sparse_lineups", "=", "False", ")", ":", "try", ":", "doc", "=", "self", ".", "get_subpage_doc", "(", "'pbp'", ")", "except", ":", "raise", "ValueError", "(", "'Error fetching PBP subpage f...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
switch_to_dir
Decorator that switches to given directory before executing function, and then returning to orignal directory.
sportsref/decorators.py
def switch_to_dir(dirPath): """ Decorator that switches to given directory before executing function, and then returning to orignal directory. """ def decorator(func): @funcutils.wraps(func) def wrapper(*args, **kwargs): orig_cwd = os.getcwd() os.chdir(dirPat...
def switch_to_dir(dirPath): """ Decorator that switches to given directory before executing function, and then returning to orignal directory. """ def decorator(func): @funcutils.wraps(func) def wrapper(*args, **kwargs): orig_cwd = os.getcwd() os.chdir(dirPat...
[ "Decorator", "that", "switches", "to", "given", "directory", "before", "executing", "function", "and", "then", "returning", "to", "orignal", "directory", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/decorators.py#L25-L41
[ "def", "switch_to_dir", "(", "dirPath", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "funcutils", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "orig_cwd", "=", "os", ".", "getcw...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
cache
Caches the HTML returned by the specified function `func`. Caches it in the user cache determined by the appdirs package.
sportsref/decorators.py
def cache(func): """Caches the HTML returned by the specified function `func`. Caches it in the user cache determined by the appdirs package. """ CACHE_DIR = appdirs.user_cache_dir('sportsref', getpass.getuser()) if not os.path.isdir(CACHE_DIR): os.makedirs(CACHE_DIR) @funcutils.wraps(...
def cache(func): """Caches the HTML returned by the specified function `func`. Caches it in the user cache determined by the appdirs package. """ CACHE_DIR = appdirs.user_cache_dir('sportsref', getpass.getuser()) if not os.path.isdir(CACHE_DIR): os.makedirs(CACHE_DIR) @funcutils.wraps(...
[ "Caches", "the", "HTML", "returned", "by", "the", "specified", "function", "func", ".", "Caches", "it", "in", "the", "user", "cache", "determined", "by", "the", "appdirs", "package", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/decorators.py#L95-L144
[ "def", "cache", "(", "func", ")", ":", "CACHE_DIR", "=", "appdirs", ".", "user_cache_dir", "(", "'sportsref'", ",", "getpass", ".", "getuser", "(", ")", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "CACHE_DIR", ")", ":", "os", ".", "makedi...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
get_class_instance_key
Returns a unique identifier for a class instantiation.
sportsref/decorators.py
def get_class_instance_key(cls, args, kwargs): """ Returns a unique identifier for a class instantiation. """ l = [id(cls)] for arg in args: l.append(id(arg)) l.extend((k, id(v)) for k, v in kwargs.items()) return tuple(sorted(l))
def get_class_instance_key(cls, args, kwargs): """ Returns a unique identifier for a class instantiation. """ l = [id(cls)] for arg in args: l.append(id(arg)) l.extend((k, id(v)) for k, v in kwargs.items()) return tuple(sorted(l))
[ "Returns", "a", "unique", "identifier", "for", "a", "class", "instantiation", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/decorators.py#L147-L155
[ "def", "get_class_instance_key", "(", "cls", ",", "args", ",", "kwargs", ")", ":", "l", "=", "[", "id", "(", "cls", ")", "]", "for", "arg", "in", "args", ":", "l", ".", "append", "(", "id", "(", "arg", ")", ")", "l", ".", "extend", "(", "(", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
memoize
A decorator for memoizing functions. Only works on functions that take simple arguments - arguments that take list-like or dict-like arguments will not be memoized, and this function will raise a TypeError.
sportsref/decorators.py
def memoize(fun): """A decorator for memoizing functions. Only works on functions that take simple arguments - arguments that take list-like or dict-like arguments will not be memoized, and this function will raise a TypeError. """ @funcutils.wraps(fun) def wrapper(*args, **kwargs): ...
def memoize(fun): """A decorator for memoizing functions. Only works on functions that take simple arguments - arguments that take list-like or dict-like arguments will not be memoized, and this function will raise a TypeError. """ @funcutils.wraps(fun) def wrapper(*args, **kwargs): ...
[ "A", "decorator", "for", "memoizing", "functions", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/decorators.py#L163-L200
[ "def", "memoize", "(", "fun", ")", ":", "@", "funcutils", ".", "wraps", "(", "fun", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "do_memoization", "=", "sportsref", ".", "get_option", "(", "'memoize'", ")", "if", "not",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.age
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.
sportsref/nba/players.py
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 ...
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 ...
[ "Returns", "the", "age", "of", "the", "player", "on", "a", "given", "date", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L60-L76
[ "def", "age", "(", "self", ",", "year", ",", "month", "=", "2", ",", "day", "=", "1", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "date_string", "=", "doc", "(", "'span[itemprop=\"birthDate\"]'", ")", ".", "attr", "(", "'data-birth'", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.height
Returns the player's height (in inches). :returns: An int representing a player's height in inches.
sportsref/nba/players.py
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 = map(int, raw.split('-')) return f...
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 = map(int, raw.split('-')) return f...
[ "Returns", "the", "player", "s", "height", "(", "in", "inches", ")", ".", ":", "returns", ":", "An", "int", "representing", "a", "player", "s", "height", "in", "inches", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L86-L96
[ "def", "height", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "raw", "=", "doc", "(", "'span[itemprop=\"height\"]'", ")", ".", "text", "(", ")", "try", ":", "feet", ",", "inches", "=", "map", "(", "int", ",", "raw", "."...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.weight
Returns the player's weight (in pounds). :returns: An int representing a player's weight in pounds.
sportsref/nba/players.py
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) retu...
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) retu...
[ "Returns", "the", "player", "s", "weight", "(", "in", "pounds", ")", ".", ":", "returns", ":", "An", "int", "representing", "a", "player", "s", "weight", "in", "pounds", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L99-L109
[ "def", "weight", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "raw", "=", "doc", "(", "'span[itemprop=\"weight\"]'", ")", ".", "text", "(", ")", "try", ":", "weight", "=", "re", ".", "match", "(", "r'(\\d+)lb'", ",", "raw...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.hand
Returns the player's handedness. :returns: 'L' for left-handed, 'R' for right-handed.
sportsref/nba/players.py
def hand(self): """Returns the player's handedness. :returns: 'L' for left-handed, 'R' for right-handed. """ doc = self.get_main_doc() hand = re.search(r'Shoots:\s*(L|R)', doc.text()).group(1) return hand
def hand(self): """Returns the player's handedness. :returns: 'L' for left-handed, 'R' for right-handed. """ doc = self.get_main_doc() hand = re.search(r'Shoots:\s*(L|R)', doc.text()).group(1) return hand
[ "Returns", "the", "player", "s", "handedness", ".", ":", "returns", ":", "L", "for", "left", "-", "handed", "R", "for", "right", "-", "handed", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L112-L118
[ "def", "hand", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "hand", "=", "re", ".", "search", "(", "r'Shoots:\\s*(L|R)'", ",", "doc", ".", "text", "(", ")", ")", ".", "group", "(", "1", ")", "return", "hand" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.draft_pick
Returns when in the draft the player was picked. :returns: TODO
sportsref/nba/players.py
def draft_pick(self): """Returns when in the draft the player was picked. :returns: TODO """ doc = self.get_main_doc() try: p_tags = doc('div#meta p') draft_p_tag = next(p for p in p_tags.items() if p.text().lower().startswith('draft')) draft_p...
def draft_pick(self): """Returns when in the draft the player was picked. :returns: TODO """ doc = self.get_main_doc() try: p_tags = doc('div#meta p') draft_p_tag = next(p for p in p_tags.items() if p.text().lower().startswith('draft')) draft_p...
[ "Returns", "when", "in", "the", "draft", "the", "player", "was", "picked", ".", ":", "returns", ":", "TODO" ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L121-L132
[ "def", "draft_pick", "(", "self", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "try", ":", "p_tags", "=", "doc", "(", "'div#meta p'", ")", "draft_p_tag", "=", "next", "(", "p", "for", "p", "in", "p_tags", ".", "items", "(", ")", "if...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player._get_stats_table
Gets a stats table from the player page; helper function that does the work for per-game, per-100-poss, etc. stats. :table_id: the ID of the HTML table. :kind: specifies regular season, playoffs, or both. One of 'R', 'P', 'B'. Defaults to 'R'. :returns: A DataFrame of stats.
sportsref/nba/players.py
def _get_stats_table(self, table_id, kind='R', summary=False): """Gets a stats table from the player page; helper function that does the work for per-game, per-100-poss, etc. stats. :table_id: the ID of the HTML table. :kind: specifies regular season, playoffs, or both. One of 'R', 'P',...
def _get_stats_table(self, table_id, kind='R', summary=False): """Gets a stats table from the player page; helper function that does the work for per-game, per-100-poss, etc. stats. :table_id: the ID of the HTML table. :kind: specifies regular season, playoffs, or both. One of 'R', 'P',...
[ "Gets", "a", "stats", "table", "from", "the", "player", "page", ";", "helper", "function", "that", "does", "the", "work", "for", "per", "-", "game", "per", "-", "100", "-", "poss", "etc", ".", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L142-L157
[ "def", "_get_stats_table", "(", "self", ",", "table_id", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "table_id", "=", "'table#{}{}'", ".", "format", "(", "'playoffs_'", "if", "kind",...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_per_game
Returns a DataFrame of per-game box score stats.
sportsref/nba/players.py
def stats_per_game(self, kind='R', summary=False): """Returns a DataFrame of per-game box score stats.""" return self._get_stats_table('per_game', kind=kind, summary=summary)
def stats_per_game(self, kind='R', summary=False): """Returns a DataFrame of per-game box score stats.""" return self._get_stats_table('per_game', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "per", "-", "game", "box", "score", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L160-L162
[ "def", "stats_per_game", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'per_game'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_totals
Returns a DataFrame of total box score statistics by season.
sportsref/nba/players.py
def stats_totals(self, kind='R', summary=False): """Returns a DataFrame of total box score statistics by season.""" return self._get_stats_table('totals', kind=kind, summary=summary)
def stats_totals(self, kind='R', summary=False): """Returns a DataFrame of total box score statistics by season.""" return self._get_stats_table('totals', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "total", "box", "score", "statistics", "by", "season", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L165-L167
[ "def", "stats_totals", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'totals'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_per36
Returns a DataFrame of per-36-minutes stats.
sportsref/nba/players.py
def stats_per36(self, kind='R', summary=False): """Returns a DataFrame of per-36-minutes stats.""" return self._get_stats_table('per_minute', kind=kind, summary=summary)
def stats_per36(self, kind='R', summary=False): """Returns a DataFrame of per-36-minutes stats.""" return self._get_stats_table('per_minute', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "per", "-", "36", "-", "minutes", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L170-L172
[ "def", "stats_per36", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'per_minute'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_per100
Returns a DataFrame of per-100-possession stats.
sportsref/nba/players.py
def stats_per100(self, kind='R', summary=False): """Returns a DataFrame of per-100-possession stats.""" return self._get_stats_table('per_poss', kind=kind, summary=summary)
def stats_per100(self, kind='R', summary=False): """Returns a DataFrame of per-100-possession stats.""" return self._get_stats_table('per_poss', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "per", "-", "100", "-", "possession", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L175-L177
[ "def", "stats_per100", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'per_poss'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_advanced
Returns a DataFrame of advanced stats.
sportsref/nba/players.py
def stats_advanced(self, kind='R', summary=False): """Returns a DataFrame of advanced stats.""" return self._get_stats_table('advanced', kind=kind, summary=summary)
def stats_advanced(self, kind='R', summary=False): """Returns a DataFrame of advanced stats.""" return self._get_stats_table('advanced', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "advanced", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L180-L182
[ "def", "stats_advanced", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'advanced'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_shooting
Returns a DataFrame of shooting stats.
sportsref/nba/players.py
def stats_shooting(self, kind='R', summary=False): """Returns a DataFrame of shooting stats.""" return self._get_stats_table('shooting', kind=kind, summary=summary)
def stats_shooting(self, kind='R', summary=False): """Returns a DataFrame of shooting stats.""" return self._get_stats_table('shooting', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "shooting", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L185-L187
[ "def", "stats_shooting", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'shooting'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.stats_pbp
Returns a DataFrame of play-by-play stats.
sportsref/nba/players.py
def stats_pbp(self, kind='R', summary=False): """Returns a DataFrame of play-by-play stats.""" return self._get_stats_table('advanced_pbp', kind=kind, summary=summary)
def stats_pbp(self, kind='R', summary=False): """Returns a DataFrame of play-by-play stats.""" return self._get_stats_table('advanced_pbp', kind=kind, summary=summary)
[ "Returns", "a", "DataFrame", "of", "play", "-", "by", "-", "play", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L190-L193
[ "def", "stats_pbp", "(", "self", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "return", "self", ".", "_get_stats_table", "(", "'advanced_pbp'", ",", "kind", "=", "kind", ",", "summary", "=", "summary", ")" ]
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.gamelog_basic
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 ...
sportsref/nba/players.py
def gamelog_basic(self, year, kind='R'): """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: ...
def gamelog_basic(self, year, kind='R'): """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: ...
[ "Returns", "a", "table", "of", "a", "player", "s", "basic", "game", "-", "by", "-", "game", "stats", "for", "a", "season", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L197-L211
[ "def", "gamelog_basic", "(", "self", ",", "year", ",", "kind", "=", "'R'", ")", ":", "doc", "=", "self", ".", "get_sub_doc", "(", "'gamelog/{}'", ".", "format", "(", "year", ")", ")", "table", "=", "(", "doc", "(", "'table#pgl_basic_playoffs'", ")", "i...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
parse_play
Parse play details from a play-by-play string describing a play. Assuming valid input, this function returns structured data in a dictionary describing the play. If the play detail string was invalid, this function returns None. :param boxscore_id: the boxscore ID of the play :param details: detai...
sportsref/nba/pbp.py
def parse_play(boxscore_id, details, is_hm): """Parse play details from a play-by-play string describing a play. Assuming valid input, this function returns structured data in a dictionary describing the play. If the play detail string was invalid, this function returns None. :param boxscore_id: t...
def parse_play(boxscore_id, details, is_hm): """Parse play details from a play-by-play string describing a play. Assuming valid input, this function returns structured data in a dictionary describing the play. If the play detail string was invalid, this function returns None. :param boxscore_id: t...
[ "Parse", "play", "details", "from", "a", "play", "-", "by", "-", "play", "string", "describing", "a", "play", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L26-L379
[ "def", "parse_play", "(", "boxscore_id", ",", "details", ",", "is_hm", ")", ":", "# if input isn't a string, return None", "if", "not", "details", "or", "not", "isinstance", "(", "details", ",", "basestring", ")", ":", "return", "None", "bs", "=", "sportsref", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
clean_features
Fixes up columns of the passed DataFrame, such as casting T/F columns to boolean and filling in NaNs for team and opp. :param df: DataFrame of play-by-play data. :returns: Dataframe with cleaned columns.
sportsref/nba/pbp.py
def clean_features(df): """Fixes up columns of the passed DataFrame, such as casting T/F columns to boolean and filling in NaNs for team and opp. :param df: DataFrame of play-by-play data. :returns: Dataframe with cleaned columns. """ df = pd.DataFrame(df) bool_vals = set([True, False, Non...
def clean_features(df): """Fixes up columns of the passed DataFrame, such as casting T/F columns to boolean and filling in NaNs for team and opp. :param df: DataFrame of play-by-play data. :returns: Dataframe with cleaned columns. """ df = pd.DataFrame(df) bool_vals = set([True, False, Non...
[ "Fixes", "up", "columns", "of", "the", "passed", "DataFrame", "such", "as", "casting", "T", "/", "F", "columns", "to", "boolean", "and", "filling", "in", "NaNs", "for", "team", "and", "opp", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L382-L412
[ "def", "clean_features", "(", "df", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "df", ")", "bool_vals", "=", "set", "(", "[", "True", ",", "False", ",", "None", ",", "np", ".", "nan", "]", ")", "sparse_cols", "=", "sparse_lineup_cols", "(", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
clean_multigame_features
TODO: Docstring for clean_multigame_features. :df: TODO :returns: TODO
sportsref/nba/pbp.py
def clean_multigame_features(df): """TODO: Docstring for clean_multigame_features. :df: TODO :returns: TODO """ df = pd.DataFrame(df) if df.index.value_counts().max() > 1: df.reset_index(drop=True, inplace=True) df = clean_features(df) # if it's many games in one DataFrame, ma...
def clean_multigame_features(df): """TODO: Docstring for clean_multigame_features. :df: TODO :returns: TODO """ df = pd.DataFrame(df) if df.index.value_counts().max() > 1: df.reset_index(drop=True, inplace=True) df = clean_features(df) # if it's many games in one DataFrame, ma...
[ "TODO", ":", "Docstring", "for", "clean_multigame_features", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L415-L434
[ "def", "clean_multigame_features", "(", "df", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "df", ")", "if", "df", ".", "index", ".", "value_counts", "(", ")", ".", "max", "(", ")", ">", "1", ":", "df", ".", "reset_index", "(", "drop", "=", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
get_period_starters
TODO
sportsref/nba/pbp.py
def get_period_starters(df): """TODO """ def players_from_play(play): """Figures out what players are in the game based on the players mentioned in a play. Returns away and home players as two sets. :param play: A dictionary representing a parsed play. :returns: (aw_players...
def get_period_starters(df): """TODO """ def players_from_play(play): """Figures out what players are in the game based on the players mentioned in a play. Returns away and home players as two sets. :param play: A dictionary representing a parsed play. :returns: (aw_players...
[ "TODO" ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L437-L504
[ "def", "get_period_starters", "(", "df", ")", ":", "def", "players_from_play", "(", "play", ")", ":", "\"\"\"Figures out what players are in the game based on the players\n mentioned in a play. Returns away and home players as two sets.\n\n :param play: A dictionary representin...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
get_sparse_lineups
TODO: Docstring for get_sparse_lineups. :param df: TODO :returns: TODO
sportsref/nba/pbp.py
def get_sparse_lineups(df): """TODO: Docstring for get_sparse_lineups. :param df: TODO :returns: TODO """ # get the lineup data using get_dense_lineups if necessary if (set(ALL_LINEUP_COLS) - set(df.columns)): lineup_df = get_dense_lineups(df) else: lineup_df = df[ALL_LINEU...
def get_sparse_lineups(df): """TODO: Docstring for get_sparse_lineups. :param df: TODO :returns: TODO """ # get the lineup data using get_dense_lineups if necessary if (set(ALL_LINEUP_COLS) - set(df.columns)): lineup_df = get_dense_lineups(df) else: lineup_df = df[ALL_LINEU...
[ "TODO", ":", "Docstring", "for", "get_sparse_lineups", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L507-L533
[ "def", "get_sparse_lineups", "(", "df", ")", ":", "# get the lineup data using get_dense_lineups if necessary", "if", "(", "set", "(", "ALL_LINEUP_COLS", ")", "-", "set", "(", "df", ".", "columns", ")", ")", ":", "lineup_df", "=", "get_dense_lineups", "(", "df", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
get_dense_lineups
Returns a new DataFrame based on the one it is passed. Specifically, it adds five columns for each team (ten total), where each column has the ID of a player on the court during the play. This information is figured out sequentially from the game's substitution data in the passed DataFrame, so the Data...
sportsref/nba/pbp.py
def get_dense_lineups(df): """Returns a new DataFrame based on the one it is passed. Specifically, it adds five columns for each team (ten total), where each column has the ID of a player on the court during the play. This information is figured out sequentially from the game's substitution data in...
def get_dense_lineups(df): """Returns a new DataFrame based on the one it is passed. Specifically, it adds five columns for each team (ten total), where each column has the ID of a player on the court during the play. This information is figured out sequentially from the game's substitution data in...
[ "Returns", "a", "new", "DataFrame", "based", "on", "the", "one", "it", "is", "passed", ".", "Specifically", "it", "adds", "five", "columns", "for", "each", "team", "(", "ten", "total", ")", "where", "each", "column", "has", "the", "ID", "of", "a", "pla...
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/pbp.py#L536-L674
[ "def", "get_dense_lineups", "(", "df", ")", ":", "# TODO: add this precondition to documentation", "assert", "df", "[", "'boxscore_id'", "]", ".", "nunique", "(", ")", "==", "1", "def", "lineup_dict", "(", "aw_lineup", ",", "hm_lineup", ")", ":", "\"\"\"Returns a ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
GamePlayFinder
Docstring will be filled in by __init__.py
sportsref/nfl/finders/GPF.py
def GamePlayFinder(**kwargs): """ Docstring will be filled in by __init__.py """ querystring = _kwargs_to_qs(**kwargs) url = '{}?{}'.format(GPF_URL, querystring) # if verbose, print url if kwargs.get('verbose', False): print(url) html = utils.get_html(url) doc = pq(html) # pars...
def GamePlayFinder(**kwargs): """ Docstring will be filled in by __init__.py """ querystring = _kwargs_to_qs(**kwargs) url = '{}?{}'.format(GPF_URL, querystring) # if verbose, print url if kwargs.get('verbose', False): print(url) html = utils.get_html(url) doc = pq(html) # pars...
[ "Docstring", "will", "be", "filled", "in", "by", "__init__", ".", "py" ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/finders/GPF.py#L20-L44
[ "def", "GamePlayFinder", "(", "*", "*", "kwargs", ")", ":", "querystring", "=", "_kwargs_to_qs", "(", "*", "*", "kwargs", ")", "url", "=", "'{}?{}'", ".", "format", "(", "GPF_URL", ",", "querystring", ")", "# if verbose, print url", "if", "kwargs", ".", "g...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_kwargs_to_qs
Converts kwargs given to GPF to a querystring. :returns: the querystring.
sportsref/nfl/finders/GPF.py
def _kwargs_to_qs(**kwargs): """Converts kwargs given to GPF to a querystring. :returns: the querystring. """ # start with defaults inpOptDef = inputs_options_defaults() opts = { name: dct['value'] for name, dct in inpOptDef.items() } # clean up keys and values for ...
def _kwargs_to_qs(**kwargs): """Converts kwargs given to GPF to a querystring. :returns: the querystring. """ # start with defaults inpOptDef = inputs_options_defaults() opts = { name: dct['value'] for name, dct in inpOptDef.items() } # clean up keys and values for ...
[ "Converts", "kwargs", "given", "to", "GPF", "to", "a", "querystring", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/finders/GPF.py#L47-L148
[ "def", "_kwargs_to_qs", "(", "*", "*", "kwargs", ")", ":", "# start with defaults", "inpOptDef", "=", "inputs_options_defaults", "(", ")", "opts", "=", "{", "name", ":", "dct", "[", "'value'", "]", "for", "name", ",", "dct", "in", "inpOptDef", ".", "items"...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
inputs_options_defaults
Handles scraping options for play finder form. :returns: {'name1': {'value': val, 'options': [opt1, ...] }, ... }
sportsref/nfl/finders/GPF.py
def inputs_options_defaults(): """Handles scraping options for play finder form. :returns: {'name1': {'value': val, 'options': [opt1, ...] }, ... } """ # set time variables if os.path.isfile(GPF_CONSTANTS_FILENAME): modtime = int(os.path.getmtime(GPF_CONSTANTS_FILENAME)) curtime = ...
def inputs_options_defaults(): """Handles scraping options for play finder form. :returns: {'name1': {'value': val, 'options': [opt1, ...] }, ... } """ # set time variables if os.path.isfile(GPF_CONSTANTS_FILENAME): modtime = int(os.path.getmtime(GPF_CONSTANTS_FILENAME)) curtime = ...
[ "Handles", "scraping", "options", "for", "play", "finder", "form", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/finders/GPF.py#L152-L251
[ "def", "inputs_options_defaults", "(", ")", ":", "# set time variables", "if", "os", ".", "path", ".", "isfile", "(", "GPF_CONSTANTS_FILENAME", ")", ":", "modtime", "=", "int", "(", "os", ".", "path", ".", "getmtime", "(", "GPF_CONSTANTS_FILENAME", ")", ")", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
DeleteHandler.get
Please don't do this in production environments.
demos/memory_session.py
def get(self): ''' Please don't do this in production environments. ''' self.write("Memory Session Object Demo:") if "sv" in self.session: current_value = self.session["sv"] self.write("current sv value is %s, and system will delete this value.<br/>" % sel...
def get(self): ''' Please don't do this in production environments. ''' self.write("Memory Session Object Demo:") if "sv" in self.session: current_value = self.session["sv"] self.write("current sv value is %s, and system will delete this value.<br/>" % sel...
[ "Please", "don", "t", "do", "this", "in", "production", "environments", "." ]
MitchellChu/torndsession
python
https://github.com/MitchellChu/torndsession/blob/dd08554c06f47d33396a0a4485f53d0522961155/demos/memory_session.py#L53-L65
[ "def", "get", "(", "self", ")", ":", "self", ".", "write", "(", "\"Memory Session Object Demo:\"", ")", "if", "\"sv\"", "in", "self", ".", "session", ":", "current_value", "=", "self", ".", "session", "[", "\"sv\"", "]", "self", ".", "write", "(", "\"cur...
dd08554c06f47d33396a0a4485f53d0522961155
test
expand_details
Expands the details column of the given dataframe and returns the resulting DataFrame. :df: The input DataFrame. :detailCol: The detail column name. :returns: Returns DataFrame with new columns from pbp parsing.
sportsref/nfl/pbp.py
def expand_details(df, detailCol='detail'): """Expands the details column of the given dataframe and returns the resulting DataFrame. :df: The input DataFrame. :detailCol: The detail column name. :returns: Returns DataFrame with new columns from pbp parsing. """ df = copy.deepcopy(df) d...
def expand_details(df, detailCol='detail'): """Expands the details column of the given dataframe and returns the resulting DataFrame. :df: The input DataFrame. :detailCol: The detail column name. :returns: Returns DataFrame with new columns from pbp parsing. """ df = copy.deepcopy(df) d...
[ "Expands", "the", "details", "column", "of", "the", "given", "dataframe", "and", "returns", "the", "resulting", "DataFrame", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L22-L52
[ "def", "expand_details", "(", "df", ",", "detailCol", "=", "'detail'", ")", ":", "df", "=", "copy", ".", "deepcopy", "(", "df", ")", "df", "[", "'detail'", "]", "=", "df", "[", "detailCol", "]", "dicts", "=", "[", "sportsref", ".", "nfl", ".", "pbp...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
parse_play_details
Parses play details from play-by-play string and returns structured data. :details: detail string for play :returns: dictionary of play attributes
sportsref/nfl/pbp.py
def parse_play_details(details): """Parses play details from play-by-play string and returns structured data. :details: detail string for play :returns: dictionary of play attributes """ # if input isn't a string, return None if not isinstance(details, basestring): return None ...
def parse_play_details(details): """Parses play details from play-by-play string and returns structured data. :details: detail string for play :returns: dictionary of play attributes """ # if input isn't a string, return None if not isinstance(details, basestring): return None ...
[ "Parses", "play", "details", "from", "play", "-", "by", "-", "play", "string", "and", "returns", "structured", "data", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L56-L358
[ "def", "parse_play_details", "(", "details", ")", ":", "# if input isn't a string, return None", "if", "not", "isinstance", "(", "details", ",", "basestring", ")", ":", "return", "None", "rushOptRE", "=", "r'(?P<rushDir>{})'", ".", "format", "(", "r'|'", ".", "joi...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_clean_features
Cleans up the features collected in parse_play_details. :struct: Pandas Series of features parsed from details string. :returns: the same dict, but with cleaner features (e.g., convert bools, ints, etc.)
sportsref/nfl/pbp.py
def _clean_features(struct): """Cleans up the features collected in parse_play_details. :struct: Pandas Series of features parsed from details string. :returns: the same dict, but with cleaner features (e.g., convert bools, ints, etc.) """ struct = dict(struct) # First, clean up play type b...
def _clean_features(struct): """Cleans up the features collected in parse_play_details. :struct: Pandas Series of features parsed from details string. :returns: the same dict, but with cleaner features (e.g., convert bools, ints, etc.) """ struct = dict(struct) # First, clean up play type b...
[ "Cleans", "up", "the", "features", "collected", "in", "parse_play_details", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L361-L480
[ "def", "_clean_features", "(", "struct", ")", ":", "struct", "=", "dict", "(", "struct", ")", "# First, clean up play type bools", "ptypes", "=", "[", "'isKickoff'", ",", "'isTimeout'", ",", "'isFieldGoal'", ",", "'isPunt'", ",", "'isKneel'", ",", "'isSpike'", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_loc_to_features
Converts a location string "{Half}, {YardLine}" into a tuple of those values, the second being an int. :l: The string from the play by play table representing location. :returns: A tuple that separates out the values, making them missing (np.nan) when necessary.
sportsref/nfl/pbp.py
def _loc_to_features(loc): """Converts a location string "{Half}, {YardLine}" into a tuple of those values, the second being an int. :l: The string from the play by play table representing location. :returns: A tuple that separates out the values, making them missing (np.nan) when necessary. "...
def _loc_to_features(loc): """Converts a location string "{Half}, {YardLine}" into a tuple of those values, the second being an int. :l: The string from the play by play table representing location. :returns: A tuple that separates out the values, making them missing (np.nan) when necessary. "...
[ "Converts", "a", "location", "string", "{", "Half", "}", "{", "YardLine", "}", "into", "a", "tuple", "of", "those", "values", "the", "second", "being", "an", "int", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L483-L505
[ "def", "_loc_to_features", "(", "loc", ")", ":", "if", "loc", ":", "if", "isinstance", "(", "loc", ",", "basestring", ")", ":", "loc", "=", "loc", ".", "strip", "(", ")", "if", "' '", "in", "loc", ":", "r", "=", "loc", ".", "split", "(", ")", "...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_add_team_columns
Function that adds 'team' and 'opp' columns to the features by iterating through the rows in order. A precondition is that the features dicts are in order in a continuous game sense and that all rows are from the same game. :features: A DataFrame with each row representing each play (in order). :return...
sportsref/nfl/pbp.py
def _add_team_columns(features): """Function that adds 'team' and 'opp' columns to the features by iterating through the rows in order. A precondition is that the features dicts are in order in a continuous game sense and that all rows are from the same game. :features: A DataFrame with each row repres...
def _add_team_columns(features): """Function that adds 'team' and 'opp' columns to the features by iterating through the rows in order. A precondition is that the features dicts are in order in a continuous game sense and that all rows are from the same game. :features: A DataFrame with each row repres...
[ "Function", "that", "adds", "team", "and", "opp", "columns", "to", "the", "features", "by", "iterating", "through", "the", "rows", "in", "order", ".", "A", "precondition", "is", "that", "the", "features", "dicts", "are", "in", "order", "in", "a", "continuo...
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L508-L537
[ "def", "_add_team_columns", "(", "features", ")", ":", "features", "=", "features", ".", "to_dict", "(", "'records'", ")", "curTm", "=", "curOpp", "=", "None", "playAfterKickoff", "=", "False", "# fill in team and opp columns", "for", "row", "in", "features", ":...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_team_and_opp
Given a dict representing a play and the current team with the ball, returns (team, opp) where team is the team with the ball and opp is the team without the ball at the end of the play. :struct: A Series/dict representing the play. :curTm: The current team with the ball; None means it's the first play...
sportsref/nfl/pbp.py
def _team_and_opp(struct, curTm=None, curOpp=None): """Given a dict representing a play and the current team with the ball, returns (team, opp) where team is the team with the ball and opp is the team without the ball at the end of the play. :struct: A Series/dict representing the play. :curTm: The...
def _team_and_opp(struct, curTm=None, curOpp=None): """Given a dict representing a play and the current team with the ball, returns (team, opp) where team is the team with the ball and opp is the team without the ball at the end of the play. :struct: A Series/dict representing the play. :curTm: The...
[ "Given", "a", "dict", "representing", "a", "play", "and", "the", "current", "team", "with", "the", "ball", "returns", "(", "team", "opp", ")", "where", "team", "is", "the", "team", "with", "the", "ball", "and", "opp", "is", "the", "team", "without", "t...
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L540-L592
[ "def", "_team_and_opp", "(", "struct", ",", "curTm", "=", "None", ",", "curOpp", "=", "None", ")", ":", "# if we don't know the current team, figure it out", "if", "pd", ".", "isnull", "(", "curTm", ")", ":", "if", "struct", "[", "'isRun'", "]", ":", "pID", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
_add_team_features
Adds extra convenience features based on teams with and without possession, with the precondition that the there are 'team' and 'opp' specified in row. :df: A DataFrame representing a game's play-by-play data after _clean_features has been called and 'team' and 'opp' have been added by _add...
sportsref/nfl/pbp.py
def _add_team_features(df): """Adds extra convenience features based on teams with and without possession, with the precondition that the there are 'team' and 'opp' specified in row. :df: A DataFrame representing a game's play-by-play data after _clean_features has been called and 'team' and 'o...
def _add_team_features(df): """Adds extra convenience features based on teams with and without possession, with the precondition that the there are 'team' and 'opp' specified in row. :df: A DataFrame representing a game's play-by-play data after _clean_features has been called and 'team' and 'o...
[ "Adds", "extra", "convenience", "features", "based", "on", "teams", "with", "and", "without", "possession", "with", "the", "precondition", "that", "the", "there", "are", "team", "and", "opp", "specified", "in", "row", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/pbp.py#L595-L628
[ "def", "_add_team_features", "(", "df", ")", ":", "assert", "df", ".", "team", ".", "notnull", "(", ")", ".", "all", "(", ")", "homeOnOff", "=", "df", "[", "'team'", "]", "==", "df", "[", "'home'", "]", "# create column for distToGoal", "df", "[", "'di...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Season._get_player_stats_table
Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'passing'. :returns: A DataFrame of stats.
sportsref/nfl/seasons.py
def _get_player_stats_table(self, subpage, table_id): """Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'passing'. :returns: A DataFrame of stats. """ doc = self.get_sub_doc(subpage) table = doc('table#{}'.format(table_id)...
def _get_player_stats_table(self, subpage, table_id): """Helper function for player season stats. :identifier: string identifying the type of stat, e.g. 'passing'. :returns: A DataFrame of stats. """ doc = self.get_sub_doc(subpage) table = doc('table#{}'.format(table_id)...
[ "Helper", "function", "for", "player", "season", "stats", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/seasons.py#L78-L87
[ "def", "_get_player_stats_table", "(", "self", ",", "subpage", ",", "table_id", ")", ":", "doc", "=", "self", ".", "get_sub_doc", "(", "subpage", ")", "table", "=", "doc", "(", "'table#{}'", ".", "format", "(", "table_id", ")", ")", "df", "=", "sportsref...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
initialWinProb
Gets the initial win probability of a game given its Vegas line. :line: The Vegas line from the home team's perspective (negative means home team is favored). :returns: A float in [0., 100.] that represents the win probability.
sportsref/nfl/winProb.py
def initialWinProb(line): """Gets the initial win probability of a game given its Vegas line. :line: The Vegas line from the home team's perspective (negative means home team is favored). :returns: A float in [0., 100.] that represents the win probability. """ line = float(line) probWin = 1...
def initialWinProb(line): """Gets the initial win probability of a game given its Vegas line. :line: The Vegas line from the home team's perspective (negative means home team is favored). :returns: A float in [0., 100.] that represents the win probability. """ line = float(line) probWin = 1...
[ "Gets", "the", "initial", "win", "probability", "of", "a", "game", "given", "its", "Vegas", "line", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/winProb.py#L6-L16
[ "def", "initialWinProb", "(", "line", ")", ":", "line", "=", "float", "(", "line", ")", "probWin", "=", "1.", "-", "norm", ".", "cdf", "(", "0.5", ",", "-", "line", ",", "13.86", ")", "probTie", "=", "norm", ".", "cdf", "(", "0.5", ",", "-", "l...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.gamelog
Gets the career gamelog of the given player. :kind: One of 'R', 'P', or 'B' (for regular season, playoffs, or both). Case-insensitive; defaults to 'R'. :year: The year for which the gamelog should be returned; if None, return entire career gamelog. Defaults to None. :returns: A D...
sportsref/nfl/players.py
def gamelog(self, year=None, kind='R'): """Gets the career gamelog of the given player. :kind: One of 'R', 'P', or 'B' (for regular season, playoffs, or both). Case-insensitive; defaults to 'R'. :year: The year for which the gamelog should be returned; if None, return entire care...
def gamelog(self, year=None, kind='R'): """Gets the career gamelog of the given player. :kind: One of 'R', 'P', or 'B' (for regular season, playoffs, or both). Case-insensitive; defaults to 'R'. :year: The year for which the gamelog should be returned; if None, return entire care...
[ "Gets", "the", "career", "gamelog", "of", "the", "given", "player", ".", ":", "kind", ":", "One", "of", "R", "P", "or", "B", "(", "for", "regular", "season", "playoffs", "or", "both", ")", ".", "Case", "-", "insensitive", ";", "defaults", "to", "R", ...
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/players.py#L196-L211
[ "def", "gamelog", "(", "self", ",", "year", "=", "None", ",", "kind", "=", "'R'", ")", ":", "url", "=", "self", ".", "_subpage_url", "(", "'gamelog'", ",", "None", ")", "# year is filtered later", "doc", "=", "pq", "(", "sportsref", ".", "utils", ".", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.passing
Gets yearly passing stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with passing stats.
sportsref/nfl/players.py
def passing(self, kind='R'): """Gets yearly passing stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with passing stats. """ doc = self.get_doc() table = (doc('table#passing') if kind == 'R' else ...
def passing(self, kind='R'): """Gets yearly passing stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with passing stats. """ doc = self.get_doc() table = (doc('table#passing') if kind == 'R' else ...
[ "Gets", "yearly", "passing", "stats", "for", "the", "player", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/players.py#L215-L225
[ "def", "passing", "(", "self", ",", "kind", "=", "'R'", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "(", "doc", "(", "'table#passing'", ")", "if", "kind", "==", "'R'", "else", "doc", "(", "'table#passing_playoffs'", ")", ")"...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player.rushing_and_receiving
Gets yearly rushing/receiving stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with rushing/receiving stats.
sportsref/nfl/players.py
def rushing_and_receiving(self, kind='R'): """Gets yearly rushing/receiving stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with rushing/receiving stats. """ doc = self.get_doc() table = (doc('table#rush...
def rushing_and_receiving(self, kind='R'): """Gets yearly rushing/receiving stats for the player. :kind: One of 'R', 'P', or 'B'. Case-insensitive; defaults to 'R'. :returns: Pandas DataFrame with rushing/receiving stats. """ doc = self.get_doc() table = (doc('table#rush...
[ "Gets", "yearly", "rushing", "/", "receiving", "stats", "for", "the", "player", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/players.py#L229-L242
[ "def", "rushing_and_receiving", "(", "self", ",", "kind", "=", "'R'", ")", ":", "doc", "=", "self", ".", "get_doc", "(", ")", "table", "=", "(", "doc", "(", "'table#rushing_and_receiving'", ")", "if", "kind", "==", "'R'", "else", "doc", "(", "'table#rush...
09f11ac856a23c96d666d1d510bb35d6f050b5c3
test
Player._plays
Returns a DataFrame of plays for a given year for a given play type (like rushing, receiving, or passing). :year: The year for the season. :play_type: A type of play for which there are plays (as of this writing, either "passing", "rushing", or "receiving") :expand_details: Bool...
sportsref/nfl/players.py
def _plays(self, year, play_type, expand_details): """Returns a DataFrame of plays for a given year for a given play type (like rushing, receiving, or passing). :year: The year for the season. :play_type: A type of play for which there are plays (as of this writing, either "pass...
def _plays(self, year, play_type, expand_details): """Returns a DataFrame of plays for a given year for a given play type (like rushing, receiving, or passing). :year: The year for the season. :play_type: A type of play for which there are plays (as of this writing, either "pass...
[ "Returns", "a", "DataFrame", "of", "plays", "for", "a", "given", "year", "for", "a", "given", "play", "type", "(", "like", "rushing", "receiving", "or", "passing", ")", "." ]
mdgoldberg/sportsref
python
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/players.py#L258-L281
[ "def", "_plays", "(", "self", ",", "year", ",", "play_type", ",", "expand_details", ")", ":", "url", "=", "self", ".", "_subpage_url", "(", "'{}-plays'", ".", "format", "(", "play_type", ")", ",", "year", ")", "doc", "=", "pq", "(", "sportsref", ".", ...
09f11ac856a23c96d666d1d510bb35d6f050b5c3