sportslabkit.io.file#

Overview#

Function#

auto_string_parser(value)

Auxiliary function to parse string values.

infer_metadata_from_filename(filename)

Try to infer metadata from filename.

load_gpsports(filename, playerid, teamid)

Load CoordinatesDataFrame from GPSPORTS file.

load_statsports(filename, playerid, teamid)

Load CoordinatesDataFrame from STATSPORTS file.

load_soccertrack_coordinates(filename, playerid, teamid)

Load CoordinatesDataFrame from soccertrack coordinates file.

is_soccertrack_coordinates(filename)

-

infer_gps_format(filename)

Try to infer GPS format from filename.

get_gps_loader(format)

Get GPS loader function for a given format.

load_codf(filename, format, playerid, teamid)

Load CoordinatesDataFrame from file.

load_gps(filenames, playerids, teamids)

Load GPS data from multiple files.

load_gps_from_yaml(yaml_path)

Load GPS data from a YAML file.

load_labelbox(filename)

Load labelbox format file to CoordinatesDataFrame.

load_mot(filename)

Load MOT format file to CoordinatesDataFrame.

load_soccertrack_bbox(filename)

Load a dataframe from a file.

is_mot(filename)

Return True if the file is MOT format.

infer_bbox_format(filename)

Try to infer the format of a given bounding box file.

get_bbox_loader(format)

Returns a function that loads the corresponding bbox format.

load_bbox(filename)

Load a BBoxDataFrame from a file.

load_df(filename, df_type)

Loads either a BBoxDataFrame or a CoordinatesDataFrame from a file.

Attributes#

PathLike

-

Functions#

sportslabkit.io.file.auto_string_parser(value: str) Any[source]#

Auxiliary function to parse string values.

Parameters:

value (str) – String value to parse.

Returns:

Parsed string value.

Return type:

value (any)

sportslabkit.io.file.infer_metadata_from_filename(filename: PathLike) collections.abc.Mapping[str, int][source]#

Try to infer metadata from filename.

Parameters:

filename (Union[str, bytes, os.PathLike[Any]]) – Filename to infer metadata from

Returns:

Dictionary with metadata

Return type:

dict[str, Union[int, str]]

sportslabkit.io.file.load_gpsports(filename: PathLike, playerid: int | None = None, teamid: int | None = None) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load CoordinatesDataFrame from GPSPORTS file.

Parameters:

filename (str) – Path to gpsports file.

Returns:

DataFrame of gpsports file.

Return type:

gpsports_dataframe(CoordinatesDataFrame)

sportslabkit.io.file.load_statsports(filename: PathLike, playerid: int | None = None, teamid: int | None = None) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load CoordinatesDataFrame from STATSPORTS file.

Parameters:

filename (str) – Path to statsports file.

Returns:

DataFrame of statsports file.

Return type:

statsports_dataframe(CoordinatesDataFrame)

sportslabkit.io.file.load_soccertrack_coordinates(filename: PathLike, playerid: int | None = None, teamid: int | None = None) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load CoordinatesDataFrame from soccertrack coordinates file.

Parameters:

filename (str) – Path to soccertrack coordinates file.

Returns:

DataFrame of soccertrack coordinates file.

Return type:

soccertrack_coordinates_dataframe(CoordinatesDataFrame)

sportslabkit.io.file.is_soccertrack_coordinates(filename: PathLike) bool[source]#
sportslabkit.io.file.infer_gps_format(filename: PathLike) str[source]#

Try to infer GPS format from filename.

Parameters:

filename (Union[str, bytes, os.PathLike[Any]]) – Filename to infer format from.

sportslabkit.io.file.get_gps_loader(format: str) collections.abc.Callable[[PathLike, int, int], sportslabkit.dataframe.CoordinatesDataFrame][source]#

Get GPS loader function for a given format.

Parameters:

format (str) – GPS format.

Returns:

GPS loader function.

Return type:

Callable[[PathLike, int, int], CoordinatesDataFrame]

sportslabkit.io.file.load_codf(filename: PathLike, format: str | None = None, playerid: int | None = None, teamid: int | None = None) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load CoordinatesDataFrame from file.

Parameters:
  • filename (Union[str, bytes, os.PathLike[Any]]) – Filename to load from.

  • format (Optional[str], optional) – Format of GPS data. Defaults to None.

  • playerid (Optional[int], optional) – Player ID. Defaults to None.

  • teamid (Optional[int], optional) – Team ID. Defaults to None.

Raises:

ValueError – If format is not provided and could not be inferred.

Returns:

DataFrame of GPS data.

Return type:

CoordinatesDataFrame

sportslabkit.io.file.load_gps(filenames: Sequence[PathLike] | PathLike, playerids: Sequence[int] | int = (), teamids: Sequence[int] | int = ()) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load GPS data from multiple files.

Parameters:
Returns:

DataFrame of merged gpsports and statsports.

Return type:

merged_dataframe(CoordinatesDataFrame)

sportslabkit.io.file.load_gps_from_yaml(yaml_path: str) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load GPS data from a YAML file.

Parameters:

yaml_path (str) – Path to yaml file.

Returns:

DataFrame of merged gpsports and statsports.

Return type:

merged_dataframe(CoordinatesDataFrame)

sportslabkit.io.file.load_labelbox(filename: PathLike) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load labelbox format file to CoordinatesDataFrame.

Parameters:

filename (str) – Path to gpsports file.

Returns:

DataFrame of gpsports file.

Return type:

gpsports_dataframe(CoordinatesDataFrame)

Notes

出力するDataFrameの列は以下の通り Time(datetime): GPS(GPSPORTS)のタイムスタンプ Lat(float): GPSの緯度 Lon(float): GPSの経度

sportslabkit.io.file.load_mot(filename: PathLike) sportslabkit.dataframe.CoordinatesDataFrame[source]#

Load MOT format file to CoordinatesDataFrame.

Parameters:

filename (str) – Path to statsports file.

Returns:

DataFrame of statsports file.

Return type:

statsports_dataframe(CoordinatesDataFrame)

Notes

出力するDataFrameの列は以下の通り Time(datetime): GPS(STATSPORTS)のタイムスタンプ Lat(float): GPSの緯度 Lon(float): GPSの経度

sportslabkit.io.file.load_soccertrack_bbox(filename: PathLike) pandas.DataFrame[source]#

Load a dataframe from a file.

Parameters:

filename (PathLike) – Path to load the dataframe.

Returns:

Dataframe loaded from the file.

Return type:

df (pd.DataFrame)

sportslabkit.io.file.is_mot(filename: PathLike) bool[source]#

Return True if the file is MOT format.

Parameters:

filename (PathLike) – Path to file.

Returns:

True if the file is MOT format.

Return type:

is_mot(bool)

sportslabkit.io.file.infer_bbox_format(filename: PathLike) str[source]#

Try to infer the format of a given bounding box file.

Parameters:

filename (PathLike) – Path to bounding box file.

Returns:

Inferred format of the bounding box file.

Return type:

format(str)

sportslabkit.io.file.get_bbox_loader(format: str) collections.abc.Callable[[PathLike], sportslabkit.dataframe.BBoxDataFrame][source]#

Returns a function that loads the corresponding bbox format.

Parameters:

format (str) – bbox format to load.

Returns:

Function that loads the corresponding bbox format.

Return type:

bbox_loader(Callable[[PathLike], BBoxDataFrame])

sportslabkit.io.file.load_bbox(filename: PathLike) sportslabkit.dataframe.BBoxDataFrame[source]#

Load a BBoxDataFrame from a file.

Parameters:

filename (PathLike) – Path to bounding box file.

Returns:

BBoxDataFrame loaded from the file.

Return type:

bbox(BBoxDataFrame)

sportslabkit.io.file.load_df(filename: PathLike, df_type: str = 'bbox') BBoxDataFrame | CoordinatesDataFrame[source]#

Loads either a BBoxDataFrame or a CoordinatesDataFrame from a file.

Parameters:
  • filename (Uinon[str, os.PathLike[Any]]) – Path to file.

  • df_type (str) – Type of dataframe to load. Either ‘bbox’ or ‘coordinates’.

Returns:

DataFrame of file.

Return type:

dataframe(Union[BBoxDataFrame, CoordinatesDataFrame])

Attributes#

sportslabkit.io.file.PathLike[source]#