impectPy 2.5.0__tar.gz → 2.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {impectPy-2.5.0 → impectPy-2.5.1}/PKG-INFO +4 -4
- {impectPy-2.5.0 → impectPy-2.5.1}/README.md +3 -3
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/__init__.py +1 -1
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/events.py +37 -24
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/helpers.py +9 -4
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/iteration_averages.py +18 -7
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/matchsums.py +65 -37
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/player_scores.py +33 -19
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/squad_scores.py +33 -19
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy.egg-info/PKG-INFO +4 -4
- {impectPy-2.5.0 → impectPy-2.5.1}/setup.py +1 -1
- {impectPy-2.5.0 → impectPy-2.5.1}/LICENSE.md +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/access_token.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/config.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/impect.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/iterations.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/match_info.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/matches.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/player_profile_scores.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/set_pieces.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/squad_coefficients.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/squad_ratings.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy/xml.py +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy.egg-info/SOURCES.txt +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy.egg-info/dependency_links.txt +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy.egg-info/requires.txt +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/impectPy.egg-info/top_level.txt +0 -0
- {impectPy-2.5.0 → impectPy-2.5.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: impectPy
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Summary: A Python package to facilitate interaction with the Impect customer API
|
|
5
5
|
Home-page: https://github.com/ImpectAPI/impectPy
|
|
6
6
|
Author: Impect
|
|
@@ -16,9 +16,9 @@ Requires-Dist: numpy<2.0,>=1.24.2
|
|
|
16
16
|
|
|
17
17
|
A package provided by: Impect GmbH
|
|
18
18
|
|
|
19
|
-
Version: v2.5.
|
|
19
|
+
Version: v2.5.1
|
|
20
20
|
|
|
21
|
-
**Updated: October
|
|
21
|
+
**Updated: October 17th 2025**
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
@@ -49,7 +49,7 @@ pip install impectPy
|
|
|
49
49
|
You can also install it from [GitHub](https://github.com/) with:
|
|
50
50
|
|
|
51
51
|
```cmd
|
|
52
|
-
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.
|
|
52
|
+
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.1
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
A package provided by: Impect GmbH
|
|
4
4
|
|
|
5
|
-
Version: v2.5.
|
|
5
|
+
Version: v2.5.1
|
|
6
6
|
|
|
7
|
-
**Updated: October
|
|
7
|
+
**Updated: October 17th 2025**
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ pip install impectPy
|
|
|
35
35
|
You can also install it from [GitHub](https://github.com/) with:
|
|
36
36
|
|
|
37
37
|
```cmd
|
|
38
|
-
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.
|
|
38
|
+
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.1
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
import pandas as pd
|
|
4
4
|
import requests
|
|
5
|
-
|
|
5
|
+
import re
|
|
6
|
+
from impectPy.helpers import RateLimitedAPI, ForbiddenError
|
|
6
7
|
from .matches import getMatchesFromHost
|
|
7
8
|
from .iterations import getIterationsFromHost
|
|
8
|
-
import re
|
|
9
9
|
|
|
10
10
|
######
|
|
11
11
|
#
|
|
@@ -119,16 +119,23 @@ def getEventsFromHost(
|
|
|
119
119
|
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
120
120
|
|
|
121
121
|
# get coaches
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
coaches_blacklisted = False
|
|
123
|
+
try:
|
|
124
|
+
coaches = pd.concat(
|
|
125
|
+
map(lambda iteration: connection.make_api_request_limited(
|
|
126
|
+
url=f"{host}/v5/customerapi/iterations/{iteration}/coaches",
|
|
127
|
+
method="GET"
|
|
128
|
+
).process_response(
|
|
129
|
+
endpoint="Coaches",
|
|
130
|
+
raise_exception=False
|
|
131
|
+
),
|
|
132
|
+
iterations),
|
|
133
|
+
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
134
|
+
except KeyError:
|
|
135
|
+
# no coaches found, create empty df
|
|
136
|
+
coaches = pd.DataFrame(columns=["id", "name"])
|
|
137
|
+
except ForbiddenError:
|
|
138
|
+
coaches_blacklisted = True
|
|
132
139
|
|
|
133
140
|
# get matches
|
|
134
141
|
matchplan = pd.concat(
|
|
@@ -265,18 +272,6 @@ def getEventsFromHost(
|
|
|
265
272
|
right_on="id",
|
|
266
273
|
how="left",
|
|
267
274
|
suffixes=("", "_right")
|
|
268
|
-
).merge(
|
|
269
|
-
coaches[["id", "name"]].rename(columns={"id": "homeCoachId", "name": "homeCoachName"}),
|
|
270
|
-
left_on="homeSquadCoachId",
|
|
271
|
-
right_on="homeCoachId",
|
|
272
|
-
how="left",
|
|
273
|
-
suffixes=("", "_right")
|
|
274
|
-
).merge(
|
|
275
|
-
coaches[["id", "name"]].rename(columns={"id": "awayCoachId", "name": "awayCoachName"}),
|
|
276
|
-
left_on="awaySquadCoachId",
|
|
277
|
-
right_on="awayCoachId",
|
|
278
|
-
how="left",
|
|
279
|
-
suffixes=("", "_right")
|
|
280
275
|
).merge(
|
|
281
276
|
iterations,
|
|
282
277
|
left_on="iterationId",
|
|
@@ -285,6 +280,21 @@ def getEventsFromHost(
|
|
|
285
280
|
suffixes=("", "_right")
|
|
286
281
|
)
|
|
287
282
|
|
|
283
|
+
if not coaches_blacklisted:
|
|
284
|
+
events = events.merge(
|
|
285
|
+
coaches[["id", "name"]].rename(columns={"id": "homeCoachId", "name": "homeCoachName"}),
|
|
286
|
+
left_on="homeSquadCoachId",
|
|
287
|
+
right_on="homeCoachId",
|
|
288
|
+
how="left",
|
|
289
|
+
suffixes=("", "_right")
|
|
290
|
+
).merge(
|
|
291
|
+
coaches[["id", "name"]].rename(columns={"id": "awayCoachId", "name": "awayCoachName"}),
|
|
292
|
+
left_on="awaySquadCoachId",
|
|
293
|
+
right_on="awayCoachId",
|
|
294
|
+
how="left",
|
|
295
|
+
suffixes=("", "_right")
|
|
296
|
+
)
|
|
297
|
+
|
|
288
298
|
if include_kpis:
|
|
289
299
|
# unnest scorings and full join with kpi list to ensure all kpis are present
|
|
290
300
|
scorings = scorings.merge(kpis, left_on="kpiId", right_on="id", how="outer") \
|
|
@@ -532,6 +542,9 @@ def getEventsFromHost(
|
|
|
532
542
|
# add kpis
|
|
533
543
|
order = order + kpi_cols
|
|
534
544
|
|
|
545
|
+
if coaches_blacklisted:
|
|
546
|
+
order = [col for col in order if col not in ["homeCoachId", "homeCoachName", "awayCoachId", "awayCoachName"]]
|
|
547
|
+
|
|
535
548
|
# reorder data
|
|
536
549
|
events = events[order]
|
|
537
550
|
|
|
@@ -15,6 +15,11 @@ import math
|
|
|
15
15
|
######
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
class ForbiddenError(Exception):
|
|
19
|
+
"""Raised when the API returns a 403 Forbidden response."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
18
23
|
class RateLimitedAPI:
|
|
19
24
|
def __init__(self, session: Optional[requests.Session] = None):
|
|
20
25
|
"""
|
|
@@ -115,10 +120,10 @@ class RateLimitedAPI:
|
|
|
115
120
|
f"Request-ID: {response.headers['x-request-id']} "
|
|
116
121
|
f"(Make sure to include this in any support request.)")
|
|
117
122
|
elif response.status_code == 403:
|
|
118
|
-
raise
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
raise ForbiddenError(f"Received status code {response.status_code} "
|
|
124
|
+
f"(You do not have access to this resource.)\n"
|
|
125
|
+
f"Request-ID: {response.headers['x-request-id']} "
|
|
126
|
+
f"(Make sure to include this in any support request.)")
|
|
122
127
|
# check status code and terminate if other error
|
|
123
128
|
else:
|
|
124
129
|
raise Exception(f"Received status code {response.status_code} "
|
|
@@ -118,13 +118,16 @@ def getPlayerIterationAveragesFromHost(
|
|
|
118
118
|
if len(averages_raw["name"][averages_raw["name"].isnull()]) > 0:
|
|
119
119
|
averages_raw["name"] = averages_raw["name"].fillna("-1")
|
|
120
120
|
|
|
121
|
-
#
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
# get KPIs without a scoring
|
|
122
|
+
mask = (
|
|
123
|
+
averages_raw.iterationId.isnull()
|
|
124
|
+
& averages_raw.squadId.isnull()
|
|
125
|
+
& averages_raw.playerId.isnull()
|
|
126
|
+
& averages_raw.position.isnull()
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# fill join cols with placeholder
|
|
130
|
+
averages_raw.loc[mask] = averages_raw.loc[mask].fillna(-1)
|
|
128
131
|
|
|
129
132
|
# get matchShares
|
|
130
133
|
match_shares_raw = averages_raw[
|
|
@@ -146,6 +149,14 @@ def getPlayerIterationAveragesFromHost(
|
|
|
146
149
|
if "-1" in averages_raw.columns:
|
|
147
150
|
averages_raw.drop(["-1"], inplace=True, axis=1)
|
|
148
151
|
|
|
152
|
+
# drop -1 rows
|
|
153
|
+
averages_raw = averages_raw[
|
|
154
|
+
~(averages_raw.iterationId == -1)
|
|
155
|
+
& ~(averages_raw.squadId == -1)
|
|
156
|
+
& ~(averages_raw.playerId == -1)
|
|
157
|
+
& ~(averages_raw.position == -1)
|
|
158
|
+
]
|
|
159
|
+
|
|
149
160
|
# merge with playDuration and matchShare
|
|
150
161
|
averages_raw = averages_raw.merge(
|
|
151
162
|
match_shares_raw,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# load packages
|
|
2
2
|
import pandas as pd
|
|
3
3
|
import requests
|
|
4
|
-
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df
|
|
4
|
+
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df, ForbiddenError
|
|
5
5
|
from .matches import getMatchesFromHost
|
|
6
6
|
from .iterations import getIterationsFromHost
|
|
7
7
|
|
|
@@ -102,16 +102,23 @@ def getPlayerMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
102
102
|
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
103
103
|
|
|
104
104
|
# get coaches
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
coaches_blacklisted = False
|
|
106
|
+
try:
|
|
107
|
+
coaches = pd.concat(
|
|
108
|
+
map(lambda iteration: connection.make_api_request_limited(
|
|
109
|
+
url=f"{host}/v5/customerapi/iterations/{iteration}/coaches",
|
|
110
|
+
method="GET"
|
|
111
|
+
).process_response(
|
|
112
|
+
endpoint="Coaches",
|
|
113
|
+
raise_exception=False
|
|
114
|
+
),
|
|
115
|
+
iterations),
|
|
116
|
+
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
117
|
+
except KeyError:
|
|
118
|
+
# no coaches found, create empty df
|
|
119
|
+
coaches = pd.DataFrame(columns=["id", "name"])
|
|
120
|
+
except ForbiddenError:
|
|
121
|
+
coaches_blacklisted = True
|
|
115
122
|
|
|
116
123
|
# get kpis
|
|
117
124
|
kpis = connection.make_api_request_limited(
|
|
@@ -248,14 +255,6 @@ def getPlayerMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
248
255
|
right_on="id",
|
|
249
256
|
how="left",
|
|
250
257
|
suffixes=("", "_right")
|
|
251
|
-
).merge(
|
|
252
|
-
coaches[["id", "name"]].rename(
|
|
253
|
-
columns={"id": "coachId", "name": "coachName"}
|
|
254
|
-
),
|
|
255
|
-
left_on="coachId",
|
|
256
|
-
right_on="coachId",
|
|
257
|
-
how="left",
|
|
258
|
-
suffixes=("", "_right")
|
|
259
258
|
).merge(
|
|
260
259
|
countries.rename(columns={"fifaName": "playerCountry"}),
|
|
261
260
|
left_on="countryId",
|
|
@@ -264,6 +263,17 @@ def getPlayerMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
264
263
|
suffixes=("", "_right")
|
|
265
264
|
)
|
|
266
265
|
|
|
266
|
+
if not coaches_blacklisted:
|
|
267
|
+
matchsums = matchsums.merge(
|
|
268
|
+
coaches[["id", "name"]].rename(
|
|
269
|
+
columns={"id": "coachId", "name": "coachName"}
|
|
270
|
+
),
|
|
271
|
+
left_on="coachId",
|
|
272
|
+
right_on="coachId",
|
|
273
|
+
how="left",
|
|
274
|
+
suffixes=("", "_right")
|
|
275
|
+
)
|
|
276
|
+
|
|
267
277
|
# rename some columns
|
|
268
278
|
matchsums = matchsums.rename(columns={
|
|
269
279
|
"scheduledDate": "dateTime",
|
|
@@ -304,6 +314,10 @@ def getPlayerMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
304
314
|
# add kpiNames to order
|
|
305
315
|
order += kpis['name'].to_list()
|
|
306
316
|
|
|
317
|
+
# check if coaches are blacklisted
|
|
318
|
+
if coaches_blacklisted:
|
|
319
|
+
order = [col for col in order if col not in ["coachId", "coachName"]]
|
|
320
|
+
|
|
307
321
|
# select columns
|
|
308
322
|
matchsums = matchsums[order]
|
|
309
323
|
|
|
@@ -395,16 +409,23 @@ def getSquadMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host: s
|
|
|
395
409
|
ignore_index=True)[["id", "name", "idMappings"]]
|
|
396
410
|
|
|
397
411
|
# get coaches
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
412
|
+
coaches_blacklisted = False
|
|
413
|
+
try:
|
|
414
|
+
coaches = pd.concat(
|
|
415
|
+
map(lambda iteration: connection.make_api_request_limited(
|
|
416
|
+
url=f"{host}/v5/customerapi/iterations/{iteration}/coaches",
|
|
417
|
+
method="GET"
|
|
418
|
+
).process_response(
|
|
419
|
+
endpoint="Coaches",
|
|
420
|
+
raise_exception=False
|
|
421
|
+
),
|
|
422
|
+
iterations),
|
|
423
|
+
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
424
|
+
except KeyError:
|
|
425
|
+
# no coaches found, create empty df
|
|
426
|
+
coaches = pd.DataFrame(columns=["id", "name"])
|
|
427
|
+
except ForbiddenError:
|
|
428
|
+
coaches_blacklisted = True
|
|
408
429
|
|
|
409
430
|
# unnest mappings
|
|
410
431
|
squads = unnest_mappings_df(squads, "idMappings").drop(["idMappings"], axis=1).drop_duplicates()
|
|
@@ -502,16 +523,19 @@ def getSquadMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host: s
|
|
|
502
523
|
right_on="squadId",
|
|
503
524
|
how="left",
|
|
504
525
|
suffixes=("", "_home")
|
|
505
|
-
).merge(
|
|
506
|
-
coaches[["id", "name"]].rename(
|
|
507
|
-
columns={"id": "coachId", "name": "coachName"}
|
|
508
|
-
),
|
|
509
|
-
left_on="coachId",
|
|
510
|
-
right_on="coachId",
|
|
511
|
-
how="left",
|
|
512
|
-
suffixes=("", "_right")
|
|
513
526
|
)
|
|
514
527
|
|
|
528
|
+
if not coaches_blacklisted:
|
|
529
|
+
matchsums = matchsums.merge(
|
|
530
|
+
coaches[["id", "name"]].rename(
|
|
531
|
+
columns={"id": "coachId", "name": "coachName"}
|
|
532
|
+
),
|
|
533
|
+
left_on="coachId",
|
|
534
|
+
right_on="coachId",
|
|
535
|
+
how="left",
|
|
536
|
+
suffixes=("", "_right")
|
|
537
|
+
)
|
|
538
|
+
|
|
515
539
|
# rename some columns
|
|
516
540
|
matchsums = matchsums.rename(columns={
|
|
517
541
|
"scheduledDate": "dateTime"
|
|
@@ -549,6 +573,10 @@ def getSquadMatchsumsFromHost(matches: list, connection: RateLimitedAPI, host: s
|
|
|
549
573
|
# reset index
|
|
550
574
|
matchsums = matchsums.reset_index()
|
|
551
575
|
|
|
576
|
+
# check if coaches are blacklisted
|
|
577
|
+
if coaches_blacklisted:
|
|
578
|
+
order = [col for col in order if col not in ["coachId", "coachName"]]
|
|
579
|
+
|
|
552
580
|
# select & order columns
|
|
553
581
|
matchsums = matchsums[order]
|
|
554
582
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# load packages
|
|
2
2
|
import pandas as pd
|
|
3
3
|
import requests
|
|
4
|
-
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df
|
|
4
|
+
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df, ForbiddenError
|
|
5
5
|
from .matches import getMatchesFromHost
|
|
6
6
|
from .iterations import getIterationsFromHost
|
|
7
7
|
|
|
@@ -151,16 +151,23 @@ def getPlayerMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host
|
|
|
151
151
|
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
152
152
|
|
|
153
153
|
# get coaches
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
coaches_blacklisted = False
|
|
155
|
+
try:
|
|
156
|
+
coaches = pd.concat(
|
|
157
|
+
map(lambda iteration: connection.make_api_request_limited(
|
|
158
|
+
url=f"{host}/v5/customerapi/iterations/{iteration}/coaches",
|
|
159
|
+
method="GET"
|
|
160
|
+
).process_response(
|
|
161
|
+
endpoint="Coaches",
|
|
162
|
+
raise_exception=False
|
|
163
|
+
),
|
|
164
|
+
iterations),
|
|
165
|
+
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
166
|
+
except KeyError:
|
|
167
|
+
# no coaches found, create empty df
|
|
168
|
+
coaches = pd.DataFrame(columns=["id", "name"])
|
|
169
|
+
except ForbiddenError:
|
|
170
|
+
coaches_blacklisted = True
|
|
164
171
|
|
|
165
172
|
# get player scores
|
|
166
173
|
scores = connection.make_api_request_limited(
|
|
@@ -350,14 +357,6 @@ def getPlayerMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host
|
|
|
350
357
|
right_on="id",
|
|
351
358
|
how="left",
|
|
352
359
|
suffixes=("", "_right")
|
|
353
|
-
).merge(
|
|
354
|
-
coaches[["id", "name"]].rename(
|
|
355
|
-
columns={"id": "coachId", "name": "coachName"}
|
|
356
|
-
),
|
|
357
|
-
left_on="coachId",
|
|
358
|
-
right_on="coachId",
|
|
359
|
-
how="left",
|
|
360
|
-
suffixes=("", "_right")
|
|
361
360
|
).merge(
|
|
362
361
|
countries.rename(columns={"fifaName": "playerCountry"}),
|
|
363
362
|
left_on="countryId",
|
|
@@ -366,6 +365,17 @@ def getPlayerMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host
|
|
|
366
365
|
suffixes=("", "_right")
|
|
367
366
|
)
|
|
368
367
|
|
|
368
|
+
if not coaches_blacklisted:
|
|
369
|
+
player_scores = player_scores.merge(
|
|
370
|
+
coaches[["id", "name"]].rename(
|
|
371
|
+
columns={"id": "coachId", "name": "coachName"}
|
|
372
|
+
),
|
|
373
|
+
left_on="coachId",
|
|
374
|
+
right_on="coachId",
|
|
375
|
+
how="left",
|
|
376
|
+
suffixes=("", "_right")
|
|
377
|
+
)
|
|
378
|
+
|
|
369
379
|
# rename some columns
|
|
370
380
|
player_scores = player_scores.rename(columns={
|
|
371
381
|
"scheduledDate": "dateTime",
|
|
@@ -406,6 +416,10 @@ def getPlayerMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host
|
|
|
406
416
|
# add kpiNames to order
|
|
407
417
|
order += scores["name"].to_list()
|
|
408
418
|
|
|
419
|
+
# check if coaches are blacklisted
|
|
420
|
+
if coaches_blacklisted:
|
|
421
|
+
order = [col for col in order if col not in ["coachId", "coachName"]]
|
|
422
|
+
|
|
409
423
|
# select columns
|
|
410
424
|
player_scores = player_scores[order]
|
|
411
425
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# load packages
|
|
2
2
|
import pandas as pd
|
|
3
3
|
import requests
|
|
4
|
-
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df
|
|
4
|
+
from impectPy.helpers import RateLimitedAPI, unnest_mappings_df, ForbiddenError
|
|
5
5
|
from .matches import getMatchesFromHost
|
|
6
6
|
from .iterations import getIterationsFromHost
|
|
7
7
|
|
|
@@ -81,16 +81,23 @@ def getSquadMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
81
81
|
ignore_index=True)[["id", "name", "idMappings"]]
|
|
82
82
|
|
|
83
83
|
# get coaches
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
coaches_blacklisted = False
|
|
85
|
+
try:
|
|
86
|
+
coaches = pd.concat(
|
|
87
|
+
map(lambda iteration: connection.make_api_request_limited(
|
|
88
|
+
url=f"{host}/v5/customerapi/iterations/{iteration}/coaches",
|
|
89
|
+
method="GET"
|
|
90
|
+
).process_response(
|
|
91
|
+
endpoint="Coaches",
|
|
92
|
+
raise_exception=False
|
|
93
|
+
),
|
|
94
|
+
iterations),
|
|
95
|
+
ignore_index=True)[["id", "name"]].drop_duplicates()
|
|
96
|
+
except KeyError:
|
|
97
|
+
# no coaches found, create empty df
|
|
98
|
+
coaches = pd.DataFrame(columns=["id", "name"])
|
|
99
|
+
except ForbiddenError:
|
|
100
|
+
coaches_blacklisted = True
|
|
94
101
|
|
|
95
102
|
# unnest mappings
|
|
96
103
|
squads = unnest_mappings_df(squads, "idMappings").drop(["idMappings"], axis=1).drop_duplicates()
|
|
@@ -189,16 +196,19 @@ def getSquadMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
189
196
|
right_on="squadId",
|
|
190
197
|
how="left",
|
|
191
198
|
suffixes=("", "_right")
|
|
192
|
-
).merge(
|
|
193
|
-
coaches[["id", "name"]].rename(
|
|
194
|
-
columns={"id": "coachId", "name": "coachName"}
|
|
195
|
-
),
|
|
196
|
-
left_on="coachId",
|
|
197
|
-
right_on="coachId",
|
|
198
|
-
how="left",
|
|
199
|
-
suffixes=("", "_right")
|
|
200
199
|
)
|
|
201
200
|
|
|
201
|
+
if not coaches_blacklisted:
|
|
202
|
+
squad_scores = squad_scores.merge(
|
|
203
|
+
coaches[["id", "name"]].rename(
|
|
204
|
+
columns={"id": "coachId", "name": "coachName"}
|
|
205
|
+
),
|
|
206
|
+
left_on="coachId",
|
|
207
|
+
right_on="coachId",
|
|
208
|
+
how="left",
|
|
209
|
+
suffixes=("", "_right")
|
|
210
|
+
)
|
|
211
|
+
|
|
202
212
|
# rename some columns
|
|
203
213
|
squad_scores = squad_scores.rename(columns={
|
|
204
214
|
"scheduledDate": "dateTime"
|
|
@@ -224,6 +234,10 @@ def getSquadMatchScoresFromHost(matches: list, connection: RateLimitedAPI, host:
|
|
|
224
234
|
"coachName"
|
|
225
235
|
]
|
|
226
236
|
|
|
237
|
+
# check if coaches are blacklisted
|
|
238
|
+
if coaches_blacklisted:
|
|
239
|
+
order = [col for col in order if col not in ["coachId", "coachName"]]
|
|
240
|
+
|
|
227
241
|
# add scoreNames to order
|
|
228
242
|
order += scores["name"].to_list()
|
|
229
243
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: impectPy
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Summary: A Python package to facilitate interaction with the Impect customer API
|
|
5
5
|
Home-page: https://github.com/ImpectAPI/impectPy
|
|
6
6
|
Author: Impect
|
|
@@ -16,9 +16,9 @@ Requires-Dist: numpy<2.0,>=1.24.2
|
|
|
16
16
|
|
|
17
17
|
A package provided by: Impect GmbH
|
|
18
18
|
|
|
19
|
-
Version: v2.5.
|
|
19
|
+
Version: v2.5.1
|
|
20
20
|
|
|
21
|
-
**Updated: October
|
|
21
|
+
**Updated: October 17th 2025**
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
@@ -49,7 +49,7 @@ pip install impectPy
|
|
|
49
49
|
You can also install it from [GitHub](https://github.com/) with:
|
|
50
50
|
|
|
51
51
|
```cmd
|
|
52
|
-
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.
|
|
52
|
+
pip install git+https://github.com/ImpectAPI/impectPy.git@v2.5.1
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
@@ -17,7 +17,7 @@ setup(
|
|
|
17
17
|
"pandas>=2.0.0",
|
|
18
18
|
"numpy>=1.24.2,<2.0"],
|
|
19
19
|
# *strongly* suggested for sharing
|
|
20
|
-
version="2.5.
|
|
20
|
+
version="2.5.1",
|
|
21
21
|
# The license can be anything you like
|
|
22
22
|
license="MIT",
|
|
23
23
|
description="A Python package to facilitate interaction with the Impect customer API",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|