text stringlengths 81 112k |
|---|
Returns a list of interface numbers from the output tshark -D. Used
internally to capture on multiple interfaces.
def get_tshark_interfaces(tshark_path=None):
"""
Returns a list of interface numbers from the output tshark -D. Used
internally to capture on multiple interfaces.
"""
parameters = [... |
Returns the special tshark parameters to be used according to the configuration of this class.
def get_parameters(self, packet_count=None):
"""
Returns the special tshark parameters to be used according to the configuration of this class.
"""
params = super(PipeCapture, self).get_parame... |
Returns a list of all the layers in the packet that are of the layer type (an incase-sensitive string).
This is in order to retrieve layers which appear multiple times in the same packet (i.e. double VLAN) which cannot be
retrieved by easier means.
def get_multiple_layers(self, layer_name):
"""... |
Make lists out of duplicate keys.
def duplicate_object_hook(ordered_pairs):
"""Make lists out of duplicate keys."""
json_dict = {}
for key, val in ordered_pairs:
existing_val = json_dict.get(key)
if not existing_val:
json_dict[key] = val
else:
if isinstance(e... |
Returns the next packet in the cap.
If the capture's keep_packets flag is True, will also keep it in the internal packet list.
def next(self):
"""
Returns the next packet in the cap.
If the capture's keep_packets flag is True, will also keep it in the internal packet list.
"""
... |
Gets a TShark XML packet object or string, and returns a pyshark Packet objec.t
:param xml_pkt: str or xml object.
:param psml_structure: a list of the fields in each packet summary in the psml data. If given, packets will
be returned as a PacketSummary object.
:return: Packet object.
def packet_from_... |
Returns the special tshark parameters to be used according to the configuration of this class.
def get_parameters(self, packet_count=None):
"""
Returns the special tshark parameters to be used according to the configuration of this class.
"""
params = super(LiveRingCapture, self).get_pa... |
Returns the special tshark parameters to be used according to the configuration of this class.
def get_parameters(self, packet_count=None):
"""
Returns the special tshark parameters to be used according to the configuration of this class.
"""
params = super(LiveCapture, self).get_parame... |
Reads the packets from the source (cap, interface, etc.) and adds it to the internal list.
If 0 as the packet_count is given, reads forever
:param packet_count: The amount of packets to add to the packet list (0 to read forever)
:param timeout: If given, automatically stops after a given amount... |
Sets the capture to debug mode (or turns it off if specified).
def set_debug(self, set_to=True):
"""
Sets the capture to debug mode (or turns it off if specified).
"""
if set_to:
StreamHandler(sys.stdout).push_application()
self._log.level = logbook.DEBUG
... |
Sets up a new eventloop as the current one according to the OS.
def _setup_eventloop(self):
"""
Sets up a new eventloop as the current one according to the OS.
"""
if os.name == 'nt':
self.eventloop = asyncio.ProactorEventLoop()
else:
self.eventloop = asy... |
Gets data containing a (part of) tshark xml.
If the given tag is found in it, returns the tag data and the remaining data.
Otherwise returns None and the same data.
:param data: string of a partial tshark xml.
:return: a tuple of (tag, data). tag will be None if none is found.
def _ex... |
Returns a generator of packets.
This is the sync version of packets_from_tshark. It wait for the completion of each coroutine and
reimplements reading packets in a sync way, yielding each packet as it arrives.
:param packet_count: If given, stops after this amount of packets is captured.
def ... |
Runs through all packets and calls the given callback (a function) with each one as it is read.
If the capture is infinite (i.e. a live capture), it will run forever, otherwise it will complete after all
packets have been read.
Example usage:
def print_callback(pkt):
print(p... |
A coroutine which creates a tshark process, runs the given callback on each packet that is received from it and
closes the process when it is done.
Do not use interactively. Can be used in order to insert packets into your own eventloop.
async def packets_from_tshark(self, packet_callback, packet_coun... |
A coroutine which goes through a stream and calls a given callback for each XML packet seen in it.
async def _go_through_packets_from_fd(self, fd, packet_callback, packet_count=None):
"""A coroutine which goes through a stream and calls a given callback for each XML packet seen in it."""
packets_captur... |
Gets the current PSML (packet summary xml) structure in a tuple ((None, leftover_data)),
only if the capture is configured to return it, else returns (None, leftover_data).
A coroutine.
async def _get_psml_struct(self, fd):
"""Gets the current PSML (packet summary xml) structure in a tuple ((N... |
A coroutine which returns a single packet if it can be read from the given StreamReader.
:return a tuple of (packet, remaining_data). The packet will be None if there was not enough XML data to create
a packet. remaining_data is the leftover data which was not enough to create a packet from.
:r... |
Returns a new tshark process with previously-set parameters.
async def _get_tshark_process(self, packet_count=None, stdin=None):
"""
Returns a new tshark process with previously-set parameters.
"""
if self.use_json:
output_type = 'json'
if not tshark_supports_jso... |
Kill the given process and properly closes any pipes connected to it.
async def _cleanup_subprocess(self, process):
"""
Kill the given process and properly closes any pipes connected to it.
"""
if process.returncode is None:
try:
process.kill()
... |
Returns the special tshark parameters to be used according to the configuration of this class.
def get_parameters(self, packet_count=None):
"""
Returns the special tshark parameters to be used according to the configuration of this class.
"""
params = []
if self._capture_filter:... |
Gets the best 'value' string this field has.
def get_default_value(self):
"""
Gets the best 'value' string this field has.
"""
val = self.show
if not val:
val = self.raw_value
if not val:
val = self.showname
return val |
Converts this field to binary (assuming it's a binary string)
def binary_value(self):
"""
Converts this field to binary (assuming it's a binary string)
"""
str_raw_value = str(self.raw_value)
if len(str_raw_value) % 2 == 1:
str_raw_value = '0' + str_raw_value
... |
Build callgraph of func_list, ignoring
built-in functions
def callgraph(G, stmt_list):
"""
Build callgraph of func_list, ignoring
built-in functions
"""
func_list = []
for stmt in stmt_list:
try:
G.add_node(stmt.head.ident.name)
func_list.append(stmt)
... |
Returns a new class with named fields.
@keyword field_defaults: A mapping from (a subset of) field names to default
values.
@keyword default: If provided, the default value for all fields without an
explicit default in `field_defaults`.
>>> Point = recordtype('Point', 'x y', default=0)
... |
one-dimensional arrays having shape [N],
row and column matrices having shape [1 N] and
[N 1] correspondingly, and their generalizations
having shape [1 1 ... N ... 1 1 1].
Scalars have shape [1 1 ... 1].
Empty arrays dont count
def isvector_or_scalar(a):
"""
one-dimensional arrays having s... |
>>> a=arange(1,10) # 1:10
>>> size(a)
matlabarray([[ 1, 10]])
def arange(start,stop,step=1,**kwargs):
"""
>>> a=arange(1,10) # 1:10
>>> size(a)
matlabarray([[ 1, 10]])
"""
expand_value = 1 if step > 0 else -1
return matlabarray(np.arange(start,
stop+... |
>>> concat([1,2,3,4,5] , [1,2,3,4,5]])
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
def concat(args):
"""
>>> concat([1,2,3,4,5] , [1,2,3,4,5]])
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
"""
import pdb
pdb.set_trace()
t = [matlabarray(a) for a in args]
return np.concatenate(t) |
>>> size(zeros(3,3)) + 1
matlabarray([[4, 4]])
def size(a, b=0, nargout=1):
"""
>>> size(zeros(3,3)) + 1
matlabarray([[4, 4]])
"""
s = np.asarray(a).shape
if s is ():
return 1 if b else (1,)*nargout
# a is not a scalar
try:
if b:
return s[b-1]
els... |
top :
| top stmt
def p_top(p):
"""
top :
| top stmt
"""
if len(p) == 1:
p[0] = node.stmt_list()
else:
p[0] = p[1]
p[0].append(p[2]) |
top : top END_FUNCTION
def p_end_function(p):
"""
top : top END_FUNCTION
"""
p[0] = p[1]
p[0].append(node.return_stmt(ret=ret_expr))
p[0].append(node.comment_stmt("\nif __name__ == '__main__':\n pass")) |
arg1 : STRING
| NUMBER
| IDENT
| GLOBAL
def p_arg1(p):
"""
arg1 : STRING
| NUMBER
| IDENT
| GLOBAL
"""
# a hack to support "clear global"
p[0] = node.string(value=str(p[1]), lineno=p.lineno(1), lexpos=p.lexpos(1)) |
arg_list : ident_init_opt
| arg_list COMMA ident_init_opt
def p_arg_list(p):
"""
arg_list : ident_init_opt
| arg_list COMMA ident_init_opt
"""
if len(p) == 2:
p[0] = node.expr_list([p[1]])
elif len(p) == 4:
p[0] = p[1]
p[0].append(p[3])
else:
... |
args : arg1
| args arg1
def p_args(p):
"""
args : arg1
| args arg1
"""
if len(p) == 2:
p[0] = node.expr_list([p[1]])
else:
p[0] = p[1]
p[0].append(p[2]) |
case_list :
| CASE expr sep stmt_list_opt case_list
| CASE expr error stmt_list_opt case_list
| OTHERWISE stmt_list
def p_case_list(p):
"""
case_list :
| CASE expr sep stmt_list_opt case_list
| CASE expr error stmt_list_opt case_list
... |
cellarray : LBRACE RBRACE
| LBRACE expr_list RBRACE
| LBRACE concat_list RBRACE
| LBRACE concat_list SEMI RBRACE
def p_cellarray(p):
"""
cellarray : LBRACE RBRACE
| LBRACE expr_list RBRACE
| LBRACE concat_list RBRACE
| LBRACE c... |
expr : expr LBRACE expr_list RBRACE
| expr LBRACE RBRACE
def p_cellarrayref(p):
"""expr : expr LBRACE expr_list RBRACE
| expr LBRACE RBRACE
"""
args = node.expr_list() if len(p) == 4 else p[3]
assert isinstance(args, node.expr_list)
p[0] = node.cellarrayref(func_expr=p[1], a... |
concat_list : expr_list SEMI expr_list
| concat_list SEMI expr_list
def p_concat_list(p):
"""
concat_list : expr_list SEMI expr_list
| concat_list SEMI expr_list
"""
if p[1].__class__ == node.expr_list:
p[0] = node.concat_list([p[1], p[3]])
else:
p[0]... |
elseif_stmt :
| ELSE stmt_list_opt
| ELSEIF expr sep stmt_list_opt elseif_stmt
| ELSEIF LPAREN expr RPAREN stmt_list_opt elseif_stmt
def p_elseif_stmt(p):
"""
elseif_stmt :
| ELSE stmt_list_opt
| ELSEIF expr sep stmt_list_opt elsei... |
expr1 : MINUS expr %prec UMINUS
| PLUS expr %prec UMINUS
| NEG expr
| HANDLE ident
| PLUSPLUS ident
| MINUSMINUS ident
def p_expr1(p):
"""expr1 : MINUS expr %prec UMINUS
| PLUS expr %prec UMINUS
| NEG expr
| HAN... |
expr2 : expr AND expr
| expr ANDAND expr
| expr BACKSLASH expr
| expr COLON expr
| expr DIV expr
| expr DOT expr
| expr DOTDIV expr
| expr DOTDIVEQ expr
| expr DOTEXP expr
| expr DOTMUL expr
... |
end : END_EXPR
def p_expr_end(p):
"end : END_EXPR"
p[0] = node.expr(
op="end", args=node.expr_list([node.number(0), node.number(0)])) |
ident : IDENT
def p_expr_ident(p):
"ident : IDENT"
global use_nargin, use_varargin
if p[1] == "varargin":
use_varargin = 1
if p[1] == "nargin":
use_nargin = 1
# import pdb; pdb.set_trace()
p[0] = node.ident(
name=p[1],
lineno=p.lineno(1),
column=p.lexpos(... |
ident_init_opt : NEG
| ident
| ident EQ expr
def p_ident_init_opt(p):
"""
ident_init_opt : NEG
| ident
| ident EQ expr
"""
if p[1] == '~':
p[0] = node.ident("__")
else:
p[0] = p[1]
if len(p) == 2:
... |
number : NUMBER
def p_expr_number(p):
"number : NUMBER"
p[0] = node.number(p[1], lineno=p.lineno(1), lexpos=p.lexpos(1)) |
expr_stmt : expr_list SEMI
def p_expr_stmt(p):
"""
expr_stmt : expr_list SEMI
"""
assert isinstance(p[1], node.expr_list)
p[0] = node.expr_stmt(expr=p[1]) |
string : STRING
def p_expr_string(p):
"string : STRING"
p[0] = node.string(p[1], lineno=p.lineno(1), lexpos=p.lexpos(1)) |
exprs : expr
| exprs COMMA expr
def p_exprs(p):
"""
exprs : expr
| exprs COMMA expr
"""
if len(p) == 2:
p[0] = node.expr_list([p[1]])
elif len(p) == 4:
p[0] = p[1]
p[0].append(p[3])
else:
assert (0)
assert isinstance(p[0], node.expr_list) |
expr : expr FIELD
def p_field_expr(p):
"""
expr : expr FIELD
"""
p[0] = node.expr(
op=".",
args=node.expr_list([
p[1], node.ident(
name=p[2], lineno=p.lineno(2), lexpos=p.lexpos(2))
])) |
foo_stmt : expr OROR expr SEMI
def p_foo_stmt(p):
"foo_stmt : expr OROR expr SEMI"
expr1 = p[1][1][0]
expr2 = p[3][1][0]
ident = expr1.ret
args1 = expr1.args
args2 = expr2.args
p[0] = node.let(ret=ident,
args=node.expr("or", node.expr_list([args1, args2]))) |
for_stmt : FOR ident EQ expr SEMI stmt_list END_STMT
| FOR LPAREN ident EQ expr RPAREN SEMI stmt_list END_STMT
| FOR matrix EQ expr SEMI stmt_list END_STMT
def p_for_stmt(p):
"""
for_stmt : FOR ident EQ expr SEMI stmt_list END_STMT
| FOR LPAREN ident EQ expr RPAREN SEMI s... |
func_stmt : FUNCTION ident lambda_args SEMI
| FUNCTION ret EQ ident lambda_args SEMI
def p_func_stmt(p):
"""func_stmt : FUNCTION ident lambda_args SEMI
| FUNCTION ret EQ ident lambda_args SEMI
"""
# stmt_list of func_stmt is set below
# marked with XYZZY
global ret... |
expr : expr LPAREN expr_list RPAREN
| expr LPAREN RPAREN
def p_funcall_expr(p):
"""expr : expr LPAREN expr_list RPAREN
| expr LPAREN RPAREN
"""
if (len(p) == 5 and len(p[3]) == 1 and p[3][0].__class__ is node.expr and
p[3][0].op == ":" and not p[3][0].args):
# fo... |
global_list : ident
| global_list ident
def p_global_list(p):
"""global_list : ident
| global_list ident
"""
if len(p) == 2:
p[0] = node.global_list([p[1]])
elif len(p) == 3:
p[0] = p[1]
p[0].append(p[2]) |
global_stmt : GLOBAL global_list SEMI
| GLOBAL ident EQ expr SEMI
def p_global_stmt(p):
"""
global_stmt : GLOBAL global_list SEMI
| GLOBAL ident EQ expr SEMI
"""
p[0] = node.global_stmt(p[2])
for ident in p[0]:
ident.props = "G" |
if_stmt : IF expr sep stmt_list_opt elseif_stmt END_STMT
| IF LPAREN expr RPAREN stmt_list_opt elseif_stmt END_STMT
def p_if_stmt(p):
"""
if_stmt : IF expr sep stmt_list_opt elseif_stmt END_STMT
| IF LPAREN expr RPAREN stmt_list_opt elseif_stmt END_STMT
"""
if len(p) == 7:
... |
matrix : LBRACKET RBRACKET
| LBRACKET concat_list RBRACKET
| LBRACKET concat_list SEMI RBRACKET
| LBRACKET expr_list RBRACKET
| LBRACKET expr_list SEMI RBRACKET
def p_matrix(p):
"""matrix : LBRACKET RBRACKET
| LBRACKET concat_list RBRACKET
... |
expr : LPAREN expr RPAREN
def p_parens_expr(p):
"""
expr : LPAREN expr RPAREN
"""
p[0] = node.expr(op="parens", args=node.expr_list([p[2]])) |
ret : ident
| LBRACKET RBRACKET
| LBRACKET expr_list RBRACKET
def p_ret(p):
"""
ret : ident
| LBRACKET RBRACKET
| LBRACKET expr_list RBRACKET
"""
if len(p) == 2:
p[0] = node.expr_list([p[1]])
elif len(p) == 3:
p[0] = node.expr_list([])
elif len(p)... |
stmt_list : stmt
| stmt_list stmt
def p_stmt_list(p):
"""
stmt_list : stmt
| stmt_list stmt
"""
if len(p) == 2:
p[0] = node.stmt_list([p[1]] if p[1] else [])
elif len(p) == 3:
p[0] = p[1]
if p[2]:
p[0].append(p[2])
else:
as... |
switch_stmt : SWITCH expr semi_opt case_list END_STMT
def p_switch_stmt(p):
"""
switch_stmt : SWITCH expr semi_opt case_list END_STMT
"""
def backpatch(expr, stmt):
if isinstance(stmt, node.if_stmt):
stmt.cond_expr.args[1] = expr
backpatch(expr, stmt.else_stmt)
bac... |
try_catch : TRY stmt_list CATCH stmt_list END_STMT
def p_try_catch(p):
"""
try_catch : TRY stmt_list CATCH stmt_list END_STMT
"""
## | TRY stmt_list END_STMT
assert isinstance(p[2], node.stmt_list)
# assert isinstance(p[4],node.stmt_list)
p[0] = node.try_catch(
try_stmt=p[2],
... |
unwind : UNWIND_PROTECT stmt_list UNWIND_PROTECT_CLEANUP stmt_list END_UNWIND_PROTECT
def p_unwind(p):
"""
unwind : UNWIND_PROTECT stmt_list UNWIND_PROTECT_CLEANUP stmt_list END_UNWIND_PROTECT
"""
p[0] = node.try_catch(
try_stmt=p[2], catch_stmt=node.expr_list(), finally_stmt=p[4]) |
while_stmt : WHILE expr SEMI stmt_list END_STMT
def p_while_stmt(p):
"""
while_stmt : WHILE expr SEMI stmt_list END_STMT
"""
assert isinstance(p[4], node.stmt_list)
p[0] = node.while_stmt(cond_expr=p[2], stmt_list=p[4]) |
To the parser, funcall is indistinguishable
from rhs array reference. But LHS references
can be converted to arrayref nodes.
def to_arrayref(u):
"""
To the parser, funcall is indistinguishable
from rhs array reference. But LHS references
can be converted to arrayref nodes.
"""
if u.__... |
Array colon subscripts foo(1:10) and colon expressions 1:10 look
too similar to each other. Now is the time to find out who is who.
def colon_subscripts(u):
"""
Array colon subscripts foo(1:10) and colon expressions 1:10 look
too similar to each other. Now is the time to find out who is who.
"""
... |
If LHS is a plain variable, and RHS is a matrix
enclosed in square brackets, replace the matrix
expr with a funcall.
def let_statement(u):
"""
If LHS is a plain variable, and RHS is a matrix
enclosed in square brackets, replace the matrix
expr with a funcall.
"""
if u.__class__ is node.... |
Convert "+++"/"---" formatted win/loss streak column into a +/- integer column
def process_win_streak(data):
"""
Convert "+++"/"---" formatted win/loss streak column into a +/- integer column
"""
#only do this if there are non-NANs in the column
if data['Streak'].count()>0:
data['Streak2'] ... |
Splits Statcast queries to avoid request timeouts
def split_request(start_dt, end_dt, player_id, url):
"""
Splits Statcast queries to avoid request timeouts
"""
current_dt = datetime.datetime.strptime(start_dt, '%Y-%m-%d')
end_dt = datetime.datetime.strptime(end_dt, '%Y-%m-%d')
results = [] # ... |
Get zip file from provided URL
def get_zip_file(url):
"""
Get zip file from provided URL
"""
with requests.get(url, stream=True) as f:
z = zipfile.ZipFile(io.BytesIO(f.content))
return z |
Pulls statcast pitch-level data from Baseball Savant for a given pitcher.
ARGUMENTS
start_dt : YYYY-MM-DD : the first date for which you want a player's statcast data
end_dt : YYYY-MM-DD : the final date for which you want data
player_id : INT : the player's MLBAM ID. Find this by calling pybaseball.pl... |
Get all batting stats for a set time range. This can be the past week, the
month of August, anything. Just supply the start and end date in YYYY-MM-DD
format.
def batting_stats_range(start_dt=None, end_dt=None):
"""
Get all batting stats for a set time range. This can be the past week, the
month of... |
Get all batting stats for a set season. If no argument is supplied, gives
stats for current season to date.
def batting_stats_bref(season=None):
"""
Get all batting stats for a set season. If no argument is supplied, gives
stats for current season to date.
"""
if season is None:
season ... |
Pull Retrosheet game logs for a given season
def season_game_logs(season):
"""
Pull Retrosheet game logs for a given season
"""
# validate input
max_year = int(datetime.now().year) - 1
if season > max_year or season < 1871:
raise ValueError('Season must be between 1871 and {}'.format(ma... |
Pull Retrosheet World Series Game Logs
def world_series_logs():
"""
Pull Retrosheet World Series Game Logs
"""
file_name = 'GLWS.TXT'
z = get_zip_file(world_series_url)
data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data |
Pull Retrosheet All Star Game Logs
def all_star_game_logs():
"""
Pull Retrosheet All Star Game Logs
"""
file_name = 'GLAS.TXT'
z = get_zip_file(all_star_url)
data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data |
Pull Retrosheet Wild Card Game Logs
def wild_card_logs():
"""
Pull Retrosheet Wild Card Game Logs
"""
file_name = 'GLWC.TXT'
z = get_zip_file(wild_card_url)
data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data |
Pull Retrosheet Division Series Game Logs
def division_series_logs():
"""
Pull Retrosheet Division Series Game Logs
"""
file_name = 'GLDV.TXT'
z = get_zip_file(division_series_url)
data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
... |
Pull Retrosheet LCS Game Logs
def lcs_logs():
"""
Pull Retrosheet LCS Game Logs
"""
file_name = 'GLLC.TXT'
z = get_zip_file(lcs_url)
data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data |
Get season-level pitching data aggregated by team.
ARGUMENTS:
start_season : int : first season you want data for (or the only season if you do not specify an end_season)
end_season : int : final season you want data for
league : "all", "nl", or "al"
ind : int : =1 if you want individual season l... |
Get season-level Pitching Statistics for Specific Team (from Baseball-Reference)
ARGUMENTS:
team : str : The Team Abbreviation (i.e. 'NYY' for Yankees) of the Team you want data for
start_season : int : first season you want data for (or the only season if you do not specify an end_season)
end_season :... |
Pulls statcast pitch-level data from Baseball Savant for a given batter.
ARGUMENTS
start_dt : YYYY-MM-DD : the first date for which you want a player's statcast data
end_dt : YYYY-MM-DD : the final date for which you want data
player_id : INT : the player's MLBAM ID. Find this by calling pybaseball.pla... |
Retrieve a table of player information given a list of player ids
:param player_ids: list of player ids
:type player_ids: list
:param key_type: name of the key type being looked up (one of "mlbam", "retro", "bbref", or "fangraphs")
:type key_type: str
:rtype: :class:`pandas.core.frame.DataFrame`
... |
Get season-level pitching data from FanGraphs.
ARGUMENTS:
start_season : int : first season you want data for (or the only season if you do not specify an end_season)
end_season : int : final season you want data for
league : "all", "nl", or "al"
qual: minimum number of pitches thrown to be inclu... |
break start and end date into smaller increments, collecting all data in small chunks and appending all results to a common dataframe
end_dt is the date strings for the final day of the query
d1 and d2 are datetime objects for first and last day of query, for doing date math
a third datetime object (d) will... |
Pulls statcast play-level data from Baseball Savant for a given date range.
INPUTS:
start_dt: YYYY-MM-DD : the first date for which you want statcast data
end_dt: YYYY-MM-DD : the last date for which you want statcast data
team: optional (defaults to None) : city abbreviation of the team you want data ... |
Pulls statcast play-level data from Baseball Savant for a single game,
identified by its MLB game ID (game_pk in statcast data)
INPUTS:
game_pk : 6-digit integer MLB game ID to retrieve
def statcast_single_game(game_pk, team=None):
"""
Pulls statcast play-level data from Baseball Savant for a sing... |
Get all pitching stats for a set time range. This can be the past week, the
month of August, anything. Just supply the start and end date in YYYY-MM-DD
format.
def pitching_stats_range(start_dt=None, end_dt=None):
"""
Get all pitching stats for a set time range. This can be the past week, the
mo... |
Get all pitching stats for a set season. If no argument is supplied, gives stats for
current season to date.
def pitching_stats_bref(season=None):
"""
Get all pitching stats for a set season. If no argument is supplied, gives stats for
current season to date.
"""
if season is None:
s... |
Get data from war_daily_pitch table. Returns WAR, its components, and a few other useful stats.
To get all fields from this table, supply argument return_all=True.
def bwar_pitch(return_all=False):
"""
Get data from war_daily_pitch table. Returns WAR, its components, and a few other useful stats.
To ... |
Decorator to mark a specified function as deprecated
:param version: version in which it is deprecated
:param replacement: replacement functions to use
def deprecated(version, *replacement):
""" Decorator to mark a specified function as deprecated
:param version: version in which it is deprecated
... |
Returns a dictionary in cloud format
:param restrict_keys: a set of keys to restrict the returned data to.
def to_api_data(self, restrict_keys=None):
""" Returns a dictionary in cloud format
:param restrict_keys: a set of keys to restrict the returned data to.
"""
cc = self._c... |
Deletes this contact
:return: Success or Failure
:rtype: bool
:raises RuntimeError: if contact is not yet saved to cloud
def delete(self):
""" Deletes this contact
:return: Success or Failure
:rtype: bool
:raises RuntimeError: if contact is not yet saved to clo... |
Saves this contact to the cloud (create or update existing one
based on what values have changed)
:return: Saved or Not
:rtype: bool
def save(self):
""" Saves this contact to the cloud (create or update existing one
based on what values have changed)
:return: Saved or ... |
This method returns a new draft Message instance with
contacts first email as a recipient
:param Recipient recipient: a Recipient instance where to send this
message. If None first email of this contact will be used
:param RecipientType recipient_type: section to add recipient into
... |
Gets a list of contacts from this address book
When querying the Global Address List the Users endpoint will be used.
Only a limited set of information will be available unless you have
access to scope 'User.Read.All' which requires App Administration
Consent.
Also using endpoi... |
Returns a Contact by it's email
:param email: email to get contact for
:return: Contact for specified email
:rtype: Contact
def get_contact_by_email(self, email):
""" Returns a Contact by it's email
:param email: email to get contact for
:return: Contact for specified ... |
Returns a list of child folders
:param int limit: max no. of folders to get. Over 999 uses batch.
:param query: applies a OData filter to the request
:type query: Query or str
:param order_by: orders the result set based on this condition
:type order_by: Query or str
:re... |
Creates a new child folder
:param str folder_name: name of the new folder to create
:return: newly created folder
:rtype: ContactFolder or None
def create_child_folder(self, folder_name):
""" Creates a new child folder
:param str folder_name: name of the new folder to create
... |
Change this folder name
:param str name: new name to change to
:return: Updated or Not
:rtype: bool
def update_folder_name(self, name):
""" Change this folder name
:param str name: new name to change to
:return: Updated or Not
:rtype: bool
"""
i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.