sc2_datasets.transforms.pandas.player_stats_to_dict

Functions

playerstats_average_to_dict(→ dict[str, float])

Exposes a logic of converting a single list of TrackerEvents

playerstats_to_dict(→ dict[str, dict[str, list[Any]]])

Exposes a logic of converting a single list of TrackerEvents to a dictionary representation

average_playerstats_dataframe(→ dict[str, float])

Averages a game dataframe.

Module Contents

playerstats_average_to_dict(sc2_replay: sc2_datasets.replay_data.sc2_replay_data.SC2ReplayData) dict[str, float]

Exposes a logic of converting a single list of TrackerEvents to a dictionary representation of the data that can be used to initialize a pandas DataFrame.

Parameters:

sc2_replay (SC2ReplayData) – Specifies a dataframe that will be averaged.

Returns:

Returns a dictionary representation of the averaged values.

Return type:

dict[str, float]

Examples

Correct Usage Examples:

This method may help you to operate with data on the game replay.

Can be used for converting average player statistics to the dictionary representation.

Then you can use it for DataFrame initialization in pandas.

You should set sc2_replay parameter.

The parameters should be set as in the examples below.

>>> playerstats_average_to_dict_object = playerstats_average_to_dict(
...        sc2_replay= sc2_replay: SC2ReplayData)
>>> assert isinstance(sc2_replay, SC2ReplayData)

Incorrect Usage Examples:

>>> wrong_type_object = int(2)
>>> playerstats_average_to_dict_object = playerstats_average_to_dict(
...        sc2_replay= wrong_type_object)
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) ...

If you don’t set parameters or paste incorect parameters’ type.

playerstats_to_dict(sc2_replay: sc2_datasets.replay_data.sc2_replay_data.SC2ReplayData, additional_data_dict: dict[str, dict[str, Any]] = {}) dict[str, dict[str, list[Any]]]

Exposes a logic of converting a single list of TrackerEvents to a dictionary representation of the data that can be used to initialize a pandas DataFrame.

Parameters:

sc2_replay (SC2ReplayData) – Specifies a replay that will be used to obtain the list of TrackerEvents to be converted.

Returns:

Returns a dictionary of features with additional information repeated for all occurrences of events.

Return type:

dict[str, dict[str, list[Any]]]

Notes

Example additional_data_dict: {“1”: {

“outcome”: 1

}

“2”: {

“outcome”: 0

}

}

Example return: Without additional data: {“1”: {“gameloop”: [1,2],

“army”: [120, 250]},

“2”: {“gameloop”: [1,2],

“army: [50, 300]}

}

With additional data (1 denoting a victory, 0 denoting a loss): {“1”: {“gameloop”: [1,2],

“army”: [120, 250], “outcome”: [1, 1]},

“2”: {“gameloop”: [1,2],

“army: [50, 300], “outcome”: [0, 0]}

}

Examples

Correct Usage Examples:

This method may help you to operate with data on the game replay.

Can be used for converting list to the dictionary representation.

Then you can use it for DataFrame initialization in pandas.

You should set sc2_replay parameter.

The parameters should be set as in the examples below.

>>> playerstats_to_dict_object = playerstats_to_dict(
...        sc2_replay= sc2_replay:SC2ReplayData)
>>> assert isinstance(sc2_replay, SC2ReplayData)

Prameter named ‘additional_data_dict’ is optional, you can leave it blank.

If you want to use this parameter, be sure that your parameter looks similar as in the example.

>>> additional_data = {
...        "1": {"outcome": 1},
...        "2": {"outcome": 2},
...     }
>>> playerstats_to_dict_object = playerstats_to_dict(
...        sc2_replay= sc2_replay: SC2ReplayData,
...        additional_data_dict = additional_data: dict)
>>> assert isinstance(sc2_replay, SC2ReplayData)
>>> assert isinstance(additional_data_dict, dict)

Incorrect Usage Examples:

>>> wrong_type_object = int(2)
>>> playerstats_to_dict_object = playerstats_to_dict(
...        sc2_replay= sc2_replay,
...        additional_data_dict = wrong_type_object)
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) ...

If you don’t set parameters or paste incorect parameters’ type.

average_playerstats_dataframe(playerstats_df: pandas.DataFrame) dict[str, float]

Averages a game dataframe.

Parameters:

playerstats_df (pd.DataFrame) – Specifies a dataframe that will be averaged.

Returns:

Returns a dictionary representation of the averaged values.

Return type:

dict[str, float]

Examples

Correct Usage Examples:

This method may help you to operate with data on the game replay. Obtains averaged game dataframe information.

You should set sc2_replay parameter.

The parameters should be set as in the example below.

>>> average_playerstats_dataframe_object = average_playerstats_dataframe(
...        playerstats_df= playerstats_df: pd.DataFrame)
>>> assert isinstance(playerstats_df, pd.DataFrame)

Incorrect Usage Examples:

>>> wrong_type_object = int(2)
>>> average_playerstats_dataframe_object = average_playerstats_dataframe(
...        playerstats_df= wrong_type_object)
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) ...

If you don’t set parameters or paste incorect parameters’ type.