diff --git a/NEWS.md b/NEWS.md index 2ae483b..ce7b269 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# impectPy 2.4.5 + +# Minor Changes +* fix bug in `getPlayerIterationAverages()`function + # impectPy 2.4.4 # Major Changes diff --git a/README.md b/README.md index 018d85c..d42a21f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ A package provided by: Impect GmbH -Version: v2.4.4 +Version: v2.4.5 -**Updated: June 5th 2025** +**Updated: June 26th 2025** --- @@ -30,7 +30,7 @@ You can install the latest version of impectPy from [GitHub](https://github.com/) with: ``` cmd -pip install git+https://github.com/ImpectAPI/impectPy.git@v2.4.4 +pip install git+https://github.com/ImpectAPI/impectPy.git@v2.4.5 ``` ## Usage diff --git a/impectPy/iteration_averages.py b/impectPy/iteration_averages.py index 6c38124..eee1c5e 100644 --- a/impectPy/iteration_averages.py +++ b/impectPy/iteration_averages.py @@ -122,13 +122,16 @@ def getPlayerIterationAveragesFromHost( if len(averages_raw["name"][averages_raw["name"].isnull()]) > 0: averages_raw["name"] = averages_raw["name"].fillna("-1") - # downcast numerics and category types - averages_raw["iterationId"] = averages_raw["iterationId"].astype("Int16") - averages_raw["squadId"] = averages_raw["squadId"].astype("Int16") - averages_raw["playerId"] = averages_raw["playerId"].astype("Int32") - averages_raw["position"] = averages_raw["position"].astype("category") - averages_raw["name"] = averages_raw["name"].astype("category") - averages_raw["value"] = averages_raw["value"].astype("Float32") + # get KPIs without a scoring + mask = ( + averages_raw.iterationId.isnull() + & averages_raw.squadId.isnull() + & averages_raw.playerId.isnull() + & averages_raw.position.isnull() + ) + + # fill join cols with placeholder + averages_raw.loc[mask] = averages_raw.loc[mask].fillna(-1) # pivot kpi values averages_raw = pd.pivot_table( @@ -146,6 +149,14 @@ def getPlayerIterationAveragesFromHost( if "-1" in averages_raw.columns: averages_raw.drop(["-1"], inplace=True, axis=1) + # drop -1 rows + averages_raw = averages_raw[ + ~(averages_raw.iterationId == -1) + & ~(averages_raw.squadId == -1) + & ~(averages_raw.playerId == -1) + & ~(averages_raw.position == -1) + ] + # merge with playDuration and matchShare averages_raw = averages_raw.merge( match_shares_raw, diff --git a/setup.py b/setup.py index bbc98af..d0a8eb1 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ "pandas>=2.0.0", "numpy>=1.24.2,<2.0"], # *strongly* suggested for sharing - version="2.4.4", + version="2.4.5", # The license can be anything you like license="MIT", description="A Python package to facilitate interaction with the Impect customer API",