_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q251100 | Task.kill | train | def kill(self):
""" Send SIGKILL to the task's process. """
logger.info('Sending SIGKILL to task {0}'.format(self.name))
if hasattr(self, 'remote_client') and self.remote_client is not None:
self.kill_sent = True
self.remote_client.close()
| python | {
"resource": ""
} |
q251101 | Task._start_check_timer | train | def _start_check_timer(self):
""" Periodically checks to see if the task has completed. """
if self.timer:
self.timer.cancel()
| python | {
"resource": ""
} |
q251102 | Task._head_temp_file | train | def _head_temp_file(self, temp_file, num_lines):
""" Returns a list of the first num_lines lines from a temp file. """
if not isinstance(num_lines, int):
raise DagobahError('num_lines must be an integer')
temp_file.seek(0)
result, curr_line = [], 0
for line | python | {
"resource": ""
} |
q251103 | Task._tail_temp_file | train | def _tail_temp_file(self, temp_file, num_lines, seek_offset=10000):
""" Returns a list of the last num_lines lines from a temp file.
This works by first moving seek_offset chars back from the end of
the file, then attempting to tail the file from there. It is
possible that fewer than nu... | python | {
"resource": ""
} |
q251104 | Task._task_complete | train | def _task_complete(self, **kwargs):
""" Performs cleanup tasks and notifies Job that the Task finished. """
logger.debug('Running _task_complete for task {0}'.format(self.name))
with self.parent_job.completion_lock:
| python | {
"resource": ""
} |
q251105 | Task._serialize | train | def _serialize(self, include_run_logs=False, strict_json=False):
""" Serialize a representation of this Task to a Python dict. """
result = {'command': self.command,
'name': self.name,
'started_at': self.started_at,
'completed_at': self.completed_at... | python | {
"resource": ""
} |
q251106 | do_login | train | def do_login():
""" Attempt to auth using single login. Rate limited at the site level. """
dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])
if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMI... | python | {
"resource": ""
} |
q251107 | return_standard_conf | train | def return_standard_conf():
""" Return the sample config file. """
result = resource_string(__name__, | python | {
"resource": ""
} |
q251108 | job_detail | train | def job_detail(job_id=None):
""" Show a detailed description of a Job's status. """
jobs = [job for job in get_jobs() if str(job['job_id']) == job_id]
if not jobs:
| python | {
"resource": ""
} |
q251109 | task_detail | train | def task_detail(job_id=None, task_name=None):
""" Show a detailed description of a specific task. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('task_detail.html',
job=job,
| python | {
"resource": ""
} |
q251110 | log_detail | train | def log_detail(job_id=None, task_name=None, log_id=None):
""" Show a detailed description of a specific log. """
jobs = get_jobs()
job = [job for job in jobs if str(job['job_id']) == job_id][0]
return render_template('log_detail.html',
job=job,
... | python | {
"resource": ""
} |
q251111 | TextEmail._task_to_text | train | def _task_to_text(self, task):
""" Return a standard formatting of a Task serialization. """
started = self._format_date(task.get('started_at', None))
completed = self._format_date(task.get('completed_at', None))
success = task.get('success', None)
success_lu = {None: 'Not exec... | python | {
"resource": ""
} |
q251112 | TextEmail._job_to_text | train | def _job_to_text(self, job):
""" Return a standard formatting of a Job serialization. """
next_run = self._format_date(job.get('next_run', None))
tasks = ''
for task in job.get('tasks', []):
tasks += self._task_to_text(task)
tasks += '\n\n'
return '\n'.... | python | {
"resource": ""
} |
q251113 | EmailTemplate._get_template | train | def _get_template(self, template_name, template_file):
""" Returns a Jinja2 template of the specified file. """
template = os.path.join(self.location, 'templates',
| python | {
"resource": ""
} |
q251114 | replace_nones | train | def replace_nones(dict_or_list):
"""Update a dict or list in place to replace
'none' string values with Python None."""
def replace_none_in_value(value):
if isinstance(value, basestring) and value.lower() == "none":
return None
return value
items = dict_or_list.iteritems() ... | python | {
"resource": ""
} |
q251115 | get_config_file | train | def get_config_file():
""" Return the loaded config file if one exists. """
# config will be created here if we can't find one
new_config_path = os.path.expanduser('~/.dagobahd.yml')
config_dirs = ['/etc',
os.path.expanduser('~')]
config_filenames = ['dagobahd.yml',
... | python | {
"resource": ""
} |
q251116 | configure_event_hooks | train | def configure_event_hooks(config):
""" Returns an EventHandler instance with registered hooks. """
def print_event_info(**kwargs):
print kwargs.get('event_params', {})
def job_complete_email(email_handler, **kwargs):
email_handler.send_job_completed(kwargs['event_params'])
def job_fai... | python | {
"resource": ""
} |
q251117 | init_core_logger | train | def init_core_logger(location, config):
""" Initialize the logger with settings from config. """
logger = logging.getLogger('dagobah')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
if get_conf(config, 'Logging.Core.enabled', False) == False:
logger.addHa... | python | {
"resource": ""
} |
q251118 | get_backend | train | def get_backend(config):
""" Returns a backend instance based on the Daemon config file. """
backend_string = get_conf(config, 'Dagobahd.backend', None)
if backend_string is None:
from ..backend.base import BaseBackend
return BaseBackend()
elif backend_string.lower() == 'mongo':
... | python | {
"resource": ""
} |
q251119 | api_call | train | def api_call(fn):
""" Returns function result in API format if requested from an API
endpoint """
@wraps(fn)
def wrapper(*args, **kwargs):
try:
result = fn(*args, **kwargs)
except (DagobahError, DAGValidationError) as e:
if request and request.endpoint == fn.__na... | python | {
"resource": ""
} |
q251120 | validate_dict | train | def validate_dict(in_dict, **kwargs):
""" Returns Boolean of whether given dict conforms to type specifications
given in kwargs. """
if not isinstance(in_dict, dict):
raise ValueError('requires a dictionary')
for key, value in kwargs.iteritems():
if key == 'required':
for ... | python | {
"resource": ""
} |
q251121 | MongoBackend.delete_dagobah | train | def delete_dagobah(self, dagobah_id):
""" Deletes the Dagobah and all child Jobs from the database.
Related run logs are deleted as well.
"""
rec = self.dagobah_coll.find_one({'_id': dagobah_id})
for job in rec.get('jobs', []):
if 'job_id' in job:
| python | {
"resource": ""
} |
q251122 | MongoBackend.commit_log | train | def commit_log(self, log_json):
""" Commits a run log to the Mongo backend.
Due to limitations of maximum document size in Mongo,
stdout and stderr logs are truncated to a maximum size for
each task.
"""
log_json['_id'] = log_json['log_id']
append = {'save_date'... | python | {
"resource": ""
} |
q251123 | BaseBackend.decode_import_json | train | def decode_import_json(self, json_doc, transformers=None):
""" Decode a JSON string based on a list of transformers.
Each transformer is a pair of ([conditional], transformer). If
all conditionals are met on each non-list, non-dict object,
the transformer tries to apply itself.
... | python | {
"resource": ""
} |
q251124 | ServerSentEventsBlueprint.publish | train | def publish(self, data, type=None, id=None, retry=None, channel='sse'):
"""
Publish data as a server-sent event.
:param data: The event data. If it is not a string, it will be
serialized to JSON using the Flask application's
:class:`~flask.json.JSONEncoder`.
:par... | python | {
"resource": ""
} |
q251125 | Env.cast | train | def cast(cls, value, cast=str, subcast=None):
"""
Parse and cast provided value.
:param value: Stringed value.
:param cast: Type or callable to cast return value as.
:param subcast: Subtype or callable to cast return values as (used for
nested structures)... | python | {
"resource": ""
} |
q251126 | Terminal.reload_list | train | def reload_list(self):
'''Press R in home view to retrieve quiz list'''
self.leetcode.load()
if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0:
self.home_view = | python | {
"resource": ""
} |
q251127 | DelaunayTri.simplices | train | def simplices(self):
"""
Returns the simplices of the triangulation.
"""
| python | {
"resource": ""
} |
q251128 | qhull_cmd | train | def qhull_cmd(cmd, options, points):
"""
Generalized helper method to perform a qhull based command.
Args:
cmd:
Command to perform. Supported commands are qconvex,
qdelaunay and qvoronoi.
options:
Options to be provided for qhull command. See specific met... | python | {
"resource": ""
} |
q251129 | qhalf | train | def qhalf(options, halfspaces, interior_point):
"""
Similar to qvoronoi command in command-line qhull.
Args:
option:
An options string. Up to two options separated by spaces
are supported. See Qhull's qhalf help for info. Typically
used options are:
F... | python | {
"resource": ""
} |
q251130 | Halfspace.from_hyperplane | train | def from_hyperplane(basis, origin, point, internal = True):
"""
Returns a Halfspace defined by a list of vectors parallel to the
bounding hyperplane.
Args:
basis: basis for the hyperplane (array with vector rows)
origin: point on the hyperplane
point:... | python | {
"resource": ""
} |
q251131 | HalfspaceIntersection.vertices | train | def vertices(self):
"""
Returns the vertices of the halfspace intersection
"""
if self._v_out is None:
output = qhalf('Fp', self.halfspaces, self.interior_point)
pts = []
for l in output[2:]:
pt = []
for c in l.split():
... | python | {
"resource": ""
} |
q251132 | Boxscore._extract_player_stats | train | def _extract_player_stats(self, table, player_dict, home_or_away):
"""
Combine all player stats into a single object.
Since each player generally has a couple of rows worth of stats (one
for basic stats and another for advanced stats) on the boxscore page,
both rows should be co... | python | {
"resource": ""
} |
q251133 | Boxscore._instantiate_players | train | def _instantiate_players(self, player_dict):
"""
Create a list of player instances for both the home and away teams.
For every player listed on the boxscores page, create an instance of
the BoxscorePlayer class for that player and add them to a list of
players for their respecti... | python | {
"resource": ""
} |
q251134 | Boxscore.winning_name | train | def winning_name(self):
"""
Returns a ``string`` of the winning team's name, such as 'Houston
Astros'.
"""
if self.winner == HOME:
| python | {
"resource": ""
} |
q251135 | Boxscore.winning_abbr | train | def winning_abbr(self):
"""
Returns a ``string`` of the winning team's abbreviation, such as 'HOU'
for the Houston Astros.
"""
if self.winner == HOME:
| python | {
"resource": ""
} |
q251136 | Boxscore.losing_name | train | def losing_name(self):
"""
Returns a ``string`` of the losing team's name, such as 'Los Angeles
| python | {
"resource": ""
} |
q251137 | Boxscore.losing_abbr | train | def losing_abbr(self):
"""
Returns a ``string`` of the losing team's abbreviation, such as 'LAD'
for the Los Angeles Dodgers.
"""
if self.winner == HOME:
| python | {
"resource": ""
} |
q251138 | Boxscores._create_url | train | def _create_url(self, date):
"""
Build the URL based on the passed datetime object.
In order to get the proper boxscore page, the URL needs to include the
requested month, day, and year.
Parameters
----------
date : datetime object | python | {
"resource": ""
} |
q251139 | Boxscores._get_score | train | def _get_score(self, score_link):
"""
Find a team's final score.
Given an HTML string of a team's boxscore, extract the integer
representing the final score and return the number.
Parameters
----------
score_link : string
An HTML string representing ... | python | {
"resource": ""
} |
q251140 | Boxscores._get_team_results | train | def _get_team_results(self, team_result_html):
"""
Extract the winning or losing team's name and abbreviation.
Depending on which team's data field is passed (either the winner or
loser), return the name and abbreviation of that team to denote which
team won and which lost the g... | python | {
"resource": ""
} |
q251141 | Boxscores._find_games | train | def _find_games(self, date, end_date):
"""
Retrieve all major games played on a given day.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that day. Any
games that are found are added to the boxscores dictio... | python | {
"resource": ""
} |
q251142 | Player._parse_season | train | def _parse_season(self, row):
"""
Parse the season string from the table.
The season is generally located in the first column of the stats tables
and should be parsed to detonate which season metrics are being pulled
from.
Parameters
----------
row : PyQ... | python | {
"resource": ""
} |
q251143 | Player._combine_season_stats | train | def _combine_season_stats(self, table_rows, career_stats, all_stats_dict):
"""
Combine all stats for each season.
Since all of the stats are spread across multiple tables, they should
be combined into a single field which can be used to easily query stats
at once.
Param... | python | {
"resource": ""
} |
q251144 | Player._parse_player_information | train | def _parse_player_information(self, player_info):
"""
Parse general player information.
Parse general player information such as height, weight, and name. The
attribute for the requested field will be set with the value prior to
returning.
Parameters
----------
... | python | {
"resource": ""
} |
q251145 | Player.dataframe | train | def dataframe(self):
"""
Returns a ``pandas DataFrame`` containing all other relevant class
properties and values where each index is a different season plus the
career stats.
"""
temp_index = self._index
rows = []
indices = []
if not self._season:... | python | {
"resource": ""
} |
q251146 | _find_year_for_season | train | def _find_year_for_season(league):
"""
Return the necessary seaons's year based on the current date.
Since all sports start and end at different times throughout the year,
simply using the current year is not sufficient to describe a season. For
example, the NCAA Men's Basketball season begins in N... | python | {
"resource": ""
} |
q251147 | _parse_abbreviation | train | def _parse_abbreviation(uri_link):
"""
Returns a team's abbreviation.
A school or team's abbreviation is generally embedded in a URI link which
contains other relative link information. For example, the URI for the
New England Patriots for the 2017 season is "/teams/nwe/2017.htm". This
function... | python | {
"resource": ""
} |
q251148 | _parse_field | train | def _parse_field(parsing_scheme, html_data, field, index=0):
"""
Parse an HTML table to find the requested field's value.
All of the values are passed in an HTML table row instead of as individual
items. The values need to be parsed by matching the requested attribute
with a parsing scheme that spo... | python | {
"resource": ""
} |
q251149 | _get_stats_table | train | def _get_stats_table(html_page, div, footer=False):
"""
Returns a generator of all rows in a requested table.
When given a PyQuery HTML object and a requested div, this function creates
a generator where every item is a PyQuery object pertaining to every row in
the table. Generally, each row will c... | python | {
"resource": ""
} |
q251150 | Teams.dataframes | train | def dataframes(self):
"""
Returns a pandas DataFrame where each row is a representation of the
Team class. Rows are indexed by the team abbreviation.
"""
frames = []
for | python | {
"resource": ""
} |
q251151 | Rankings._get_team | train | def _get_team(self, team):
"""
Retrieve team's name and abbreviation.
The team's name and abbreviation are embedded within the 'school_name'
tag and, in the case of the abbreviation, require special parsing as it
is located in the middle of a URI. The name and abbreviation are
... | python | {
"resource": ""
} |
q251152 | Rankings._find_rankings | train | def _find_rankings(self, year):
"""
Retrieve the rankings for each week.
Find and retrieve all AP rankings for the requested year and combine
them on a per-week basis. Each week contains information about the
name, abbreviation, rank, movement, and previous rank for each team
... | python | {
"resource": ""
} |
q251153 | Rankings.current | train | def current(self):
"""
Returns a ``dictionary`` of the most recent rankings from the
Associated Press where each key is a ``string`` of the team's
abbreviation and each value is an ``int`` of the team's rank for the
current week.
"""
| python | {
"resource": ""
} |
q251154 | Boxscore._retrieve_html_page | train | def _retrieve_html_page(self, uri):
"""
Download the requested HTML page.
Given a relative link, download the requested page and strip it of all
comment tags before returning a pyquery object which will be used to
parse the data.
Parameters
----------
ur... | python | {
"resource": ""
} |
q251155 | Boxscore.dataframe | train | def dataframe(self):
"""
Returns a pandas DataFrame containing all other class properties and
values. The index for the DataFrame is the string URI that is used to
instantiate the class, such as '201802040nwe'.
"""
if self._away_points is None and self._home_points is Non... | python | {
"resource": ""
} |
q251156 | Boxscore.away_abbreviation | train | def away_abbreviation(self):
"""
Returns a ``string`` of the away team's abbreviation, such as 'NWE'.
"""
| python | {
"resource": ""
} |
q251157 | Boxscore.home_abbreviation | train | def home_abbreviation(self):
"""
Returns a ``string`` of the home team's abbreviation, such as 'KAN'.
"""
| python | {
"resource": ""
} |
q251158 | Boxscores._find_games | train | def _find_games(self, week, year, end_week):
"""
Retrieve all major games played for a given week.
Builds a URL based on the requested date and downloads the HTML
contents before parsing any and all games played during that week. Any
games that are found are added to the boxscor... | python | {
"resource": ""
} |
q251159 | Game.result | train | def result(self):
"""
Returns a ``string`` constant to indicate whether the team lost in
regulation, lost in overtime, or won.
"""
if self._result.lower() == 'w':
return | python | {
"resource": ""
} |
q251160 | Game.overtime | train | def overtime(self):
"""
Returns an ``int`` of the number of overtimes that were played during
the game, or an int constant if the game went to a shootout.
"""
if self._overtime.lower() == 'ot':
return 1
if self._overtime.lower() == 'so':
| python | {
"resource": ""
} |
q251161 | Game.datetime | train | def datetime(self):
"""
Returns a datetime object to indicate the month, day, year, and time
the requested game took place.
"""
date_string = '%s %s' % (self._date, self._time.upper())
date_string = re.sub(r'/.*', '', date_string)
date_string = re.sub(r' ET', '', ... | python | {
"resource": ""
} |
q251162 | Game.type | train | def type(self):
"""
Returns a ``string`` constant to indicate whether the game was played
during the regular season or in the post season.
"""
if self._type.lower() == 'reg':
return REGULAR_SEASON
if self._type.lower() == 'ctourn':
return CONFERENC... | python | {
"resource": ""
} |
q251163 | Game.location | train | def location(self):
"""
Returns a ``string`` constant to indicate whether the game was played
at the team's home venue, the opponent's venue, or at a neutral site.
"""
if self._location == '':
| python | {
"resource": ""
} |
q251164 | Game.opponent_name | train | def opponent_name(self):
"""
Returns a ``string`` of the opponent's name, such as the 'Purdue
Boilermakers'.
""" | python | {
"resource": ""
} |
q251165 | Game.opponent_rank | train | def opponent_rank(self):
"""
Returns a ``string`` of the opponent's rank when the game was played
and None if the team was unranked.
"""
| python | {
"resource": ""
} |
q251166 | Game.overtimes | train | def overtimes(self):
"""
Returns an ``int`` of the number of overtimes that were played during
the game and 0 if the game finished at the end of regulation time.
"""
if self._overtimes == '' or self._overtimes is None:
return 0
if self._overtimes.lower() == 'o... | python | {
"resource": ""
} |
q251167 | Player._parse_nationality | train | def _parse_nationality(self, player_info):
"""
Parse the player's nationality.
The player's nationality is denoted by a flag in the information
section with a country code for each nation. The country code needs to
pulled and then matched to find the player's home country. Once ... | python | {
"resource": ""
} |
q251168 | Player._parse_contract_headers | train | def _parse_contract_headers(self, table):
"""
Parse the years on the contract.
The years are listed as the headers on the contract. The first header
contains 'Team' which specifies the player's current team and should
not be included in the years.
Parameters
---... | python | {
"resource": ""
} |
q251169 | Player._parse_contract_wages | train | def _parse_contract_wages(self, table):
"""
Parse the wages on the contract.
The wages are listed as the data points in the contract table. Any
values that don't have a value which starts with a '$' sign are likely
not valid and should be dropped.
Parameters
---... | python | {
"resource": ""
} |
q251170 | Player._combine_contract | train | def _combine_contract(self, years, wages):
"""
Combine the contract wages and year.
Match the wages with the year and add to a dictionary representing the
player's contract.
Parameters
----------
years : list
A list where each element is a string den... | python | {
"resource": ""
} |
q251171 | Player._find_initial_index | train | def _find_initial_index(self):
"""
Find the index of career stats.
When the Player class is instantiated, the default stats to pull are
the player's career stats. Upon being called, the index of the 'Career'
element should be the index value.
"""
| python | {
"resource": ""
} |
q251172 | Player._parse_player_position | train | def _parse_player_position(self, player_info):
"""
Parse the player's position.
The player's position isn't contained within a unique tag and the
player's meta information should be iterated through until 'Position'
is found as it contains the desired text.
Parameters
... | python | {
"resource": ""
} |
q251173 | Player._parse_conference | train | def _parse_conference(self, stats):
"""
Parse the conference abbreviation for the player's team.
The conference abbreviation is embedded within the conference name tag
and should be special-parsed to extract it.
Parameters
----------
stats : PyQuery object
... | python | {
"resource": ""
} |
q251174 | Player._parse_team_abbreviation | train | def _parse_team_abbreviation(self, stats):
"""
Parse the team abbreviation.
The team abbreviation is embedded within the team name tag and should
be special-parsed to extract it.
Parameters
----------
stats : PyQuery object
A PyQuery object containin... | python | {
"resource": ""
} |
q251175 | AbstractPlayer._parse_player_data | train | def _parse_player_data(self, player_data):
"""
Parse all player information and set attributes.
Iterate through each class attribute to parse the data from the HTML
page and set the attribute value with the result.
Parameters
----------
player_data : dictionary ... | python | {
"resource": ""
} |
q251176 | Boxscore._parse_ranking | train | def _parse_ranking(self, field, boxscore):
"""
Parse each team's rank if applicable.
Retrieve the team's rank according to the rankings published each week.
The ranking for the week is only located in the scores section at
the top of the page and not in the actual boxscore infor... | python | {
"resource": ""
} |
q251177 | Boxscore._parse_record | train | def _parse_record(self, field, boxscore, index):
"""
Parse each team's record.
Find the record for both the home and away teams which are listed above
the basic boxscore stats tables. Depending on whether or not the
advanced stats table is included on the page (generally only fo... | python | {
"resource": ""
} |
q251178 | Boxscore.winning_name | train | def winning_name(self):
"""
Returns a ``string`` of the winning team's name, such as 'Purdue
Boilermakers'.
"""
if self.winner == HOME:
if 'cbb/schools' not in str(self._home_name):
return str(self._home_name)
| python | {
"resource": ""
} |
q251179 | Boxscore.losing_name | train | def losing_name(self):
"""
Returns a ``string`` of the losing team's name, such as 'Indiana'
Hoosiers'.
"""
if self.winner == HOME:
if 'cbb/schools' not in str(self._away_name):
return str(self._away_name)
| python | {
"resource": ""
} |
q251180 | Boxscore.away_win_percentage | train | def away_win_percentage(self):
"""
Returns a ``float`` of the percentage of games the away team has won
after the conclusion of the game. Percentage ranges from 0-1.
"""
try:
result = float(self.away_wins) | python | {
"resource": ""
} |
q251181 | Boxscore.away_wins | train | def away_wins(self):
"""
Returns an ``int`` of the number of games the team has won after the
conclusion of the game.
"""
try:
wins, losses = | python | {
"resource": ""
} |
q251182 | Boxscore.home_win_percentage | train | def home_win_percentage(self):
"""
Returns a ``float`` of the percentage of games the home team has won
after the conclusion of the game. Percentage ranges from 0-1.
"""
try:
result = float(self.home_wins) | python | {
"resource": ""
} |
q251183 | Boxscores._get_rank | train | def _get_rank(self, team):
"""
Find the team's rank when applicable.
If a team is ranked, it will showup in a separate <span> tag with the
actual rank embedded between parentheses. When a team is ranked, the
integer value representing their ranking should be returned. For teams
... | python | {
"resource": ""
} |
q251184 | Boxscores._get_team_results | train | def _get_team_results(self, away_name, away_abbr, away_score, home_name,
home_abbr, home_score):
"""
Determine the winner and loser of the game.
If the game has been completed and sports-reference has been updated
with the score, determine the winner and loser ... | python | {
"resource": ""
} |
q251185 | Team.two_point_field_goal_percentage | train | def two_point_field_goal_percentage(self):
"""
Returns a ``float`` of the number of two point field goals made divided
by the number of two point field goal attempts. Percentage ranges from
0-1.
"""
try:
| python | {
"resource": ""
} |
q251186 | Team.opp_two_point_field_goal_percentage | train | def opp_two_point_field_goal_percentage(self):
"""
Returns a ``float`` of the number of two point field goals made divided
by the number of two point field goal attempts by opponents. Percentage
ranges from 0-1.
"""
try:
| python | {
"resource": ""
} |
q251187 | Teams._add_stats_data | train | def _add_stats_data(self, teams_list, team_data_dict):
"""
Add a team's stats row to a dictionary.
Pass table contents and a stats dictionary of all teams to accumulate
all stats for each team in a single variable.
Parameters
----------
teams_list : generator
... | python | {
"resource": ""
} |
q251188 | Conference._get_team_abbreviation | train | def _get_team_abbreviation(self, team):
"""
Retrieve team's abbreviation.
The team's abbreviation is embedded within the 'school_name' tag and
requires special parsing as it is located in the middle of a URI. The
abbreviation is returned for the requested school.
Parame... | python | {
"resource": ""
} |
q251189 | Conference._find_conference_teams | train | def _find_conference_teams(self, conference_abbreviation, year):
"""
Retrieve the teams in the conference for the requested season.
Find and retrieve all teams that participated in a conference for a
given season. The name and abbreviation for each team are parsed and
recorded t... | python | {
"resource": ""
} |
q251190 | Conferences._get_conference_id | train | def _get_conference_id(self, conference):
"""
Get the conference abbreviation, such as 'big-12'.
The conference abbreviation is embedded within the Conference Name
tag and requires special parsing to extract. The abbreviation is
returned as a string.
Parameters
... | python | {
"resource": ""
} |
q251191 | Conferences._find_conferences | train | def _find_conferences(self, year):
"""
Retrieve the conferences and teams for the requested season.
Find and retrieve all conferences for a given season and parse all of
the teams that participated in the conference during that year.
Conference information includes abbreviation ... | python | {
"resource": ""
} |
q251192 | Game.week | train | def week(self):
"""
Returns an ``int`` of the week number in the season, such as 1 for the
first week of the regular season.
"""
if self._week.lower() == 'wild card':
return WILD_CARD
if self._week.lower() == 'division':
| python | {
"resource": ""
} |
q251193 | Game.datetime | train | def datetime(self):
"""
Returns a datetime object representing the date the game was played.
"""
date_string = '%s %s %s' % (self._day,
| python | {
"resource": ""
} |
q251194 | Schedule._add_games_to_schedule | train | def _add_games_to_schedule(self, schedule, game_type, year):
"""
Add games instances to schedule.
Create a Game instance for every applicable game in the season and
append the instance to the '_game' property.
Parameters
----------
schedule : PyQuery object
... | python | {
"resource": ""
} |
q251195 | BoxscorePlayer.minutes_played | train | def minutes_played(self):
"""
Returns a ``float`` of the number of game minutes the player was on the
court for.
"""
if self._minutes_played[self._index]:
minutes, | python | {
"resource": ""
} |
q251196 | BoxscorePlayer.two_pointers | train | def two_pointers(self):
"""
Returns an ``int`` of the total number of two point field goals the
player made.
"""
if self.field_goals and self.three_pointers:
return int(self.field_goals - self.three_pointers)
# Occurs when the player didn't make any three poin... | python | {
"resource": ""
} |
q251197 | BoxscorePlayer.two_point_attempts | train | def two_point_attempts(self):
"""
Returns an ``int`` of the total number of two point field goals the
player attempted during the season.
"""
if self.field_goal_attempts and self.three_point_attempts:
return int(self.field_goal_attempts - self.three_point_attempts)
... | python | {
"resource": ""
} |
q251198 | BoxscorePlayer.two_point_percentage | train | def two_point_percentage(self):
"""
Returns a ``float`` of the player's two point field goal percentage
during the season. Percentage ranges from 0-1.
"""
if self.two_pointers and self.two_point_attempts: | python | {
"resource": ""
} |
q251199 | Boxscore.away_two_point_field_goal_percentage | train | def away_two_point_field_goal_percentage(self):
"""
Returns a ``float`` of the number of two point field goals made divided
by the number of two point field goal attempts by the away team.
Percentage ranges from 0-1.
"""
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.