sportslabkit.dataframe.base#
Overview#
- |
Classes#
- class sportslabkit.dataframe.base.BaseSLKDataFrame[source]#
Bases:
pandas.DataFrameOverview
Methods# save_dataframe(path_or_buf)Save a dataframe to a file.
get_data(frame, playerid, teamid, attributes)Get specific data from the dataframe.
iter_frames(apply_func)Iterate over the frames of the dataframe.
iter_players(apply_func, drop)Iterate over the players of the dataframe.
iter_teams(apply_func, drop)Iterate over the teams of the dataframe.
iter_attributes(apply_func, drop)Iterate over the attributes of the dataframe.
to_long_df(level, dropna)Convert a dataframe to a long format.
Check if the dataframe is in long format.
get_frame(frame)Get a specific frame from the dataframe.
Members
- save_dataframe(path_or_buf: FilePath | WriteBuffer[bytes] | WriteBuffer[str]) None[source]#
Save a dataframe to a file.
- get_data(frame=None, playerid=None, teamid=None, attributes=None)[source]#
Get specific data from the dataframe.
- Parameters:
- Returns:
Dataframe with the selected data.
- Return type:
pd.DataFrame
- iter_frames(apply_func=None)[source]#
Iterate over the frames of the dataframe.
- Parameters:
apply_func (function, optional) – Function to apply to each group. Defaults to None.
- iter_players(apply_func=None, drop=True)[source]#
Iterate over the players of the dataframe.
- Parameters:
apply_func (function, optional) – Function to apply to each group. Defaults to None.
drop (bool, optional) – Drop the level of the dataframe. Defaults to True.
- iter_teams(apply_func=None, drop=True)[source]#
Iterate over the teams of the dataframe.
- Parameters:
apply_func (function, optional) – Function to apply to each group. Defaults to None.
drop (bool, optional) – Drop the level of the dataframe. Defaults to True.
- iter_attributes(apply_func=None, drop=True)[source]#
Iterate over the attributes of the dataframe.
- Parameters:
apply_func (function, optional) – Function to apply to each group. Defaults to None.
drop (bool, optional) – Drop the level of the dataframe. Defaults to True.
- to_long_df(level='Attributes', dropna=True)[source]#
Convert a dataframe to a long format.
- Parameters:
df (pd.DataFrame) – Dataframe to convert.
level (str, optional) – Level to convert to long format. Defaults to ‘Attributes’. Options are ‘Attributes’, ‘TeamID’, ‘PlayerID’.
- Returns:
Dataframe in long format.
- Return type:
pd.DataFrame