rustat-python-api 0.5.8__py3-none-any.whl → 0.5.9__py3-none-any.whl

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.
@@ -13,20 +13,27 @@ def process_list(x: pd.Series):
13
13
  else:
14
14
  return lst
15
15
 
16
+ def take_last(x: pd.Series):
17
+ lst = x.dropna().tolist()
18
+ if lst:
19
+ return lst[-1]
20
+ return np.nan
21
+
16
22
 
17
23
  def gluing(df: pd.DataFrame) -> pd.DataFrame:
18
24
  cols = ['player_id', 'half', 'second', 'pos_x', 'pos_y']
19
25
 
20
- df_gb = df.groupby(cols).agg(process_list).reset_index()
21
- df_gb['possession_number'] = df_gb['possession_number'].apply(
22
- lambda x: max(x) if isinstance(x, list) else x
23
- )
24
- df_gb['pos_dest_x'] = df_gb['pos_dest_x'].apply(
25
- lambda x: x[0] if isinstance(x, list) else x
26
- )
27
- df_gb['pos_dest_y'] = df_gb['pos_dest_y'].apply(
28
- lambda x: x[0] if isinstance(x, list) else x
29
- )
26
+ agg_rules = {}
27
+
28
+ for col_name in df.columns:
29
+ if col_name not in cols:
30
+ if col_name in ['action_name', 'action_id']:
31
+ agg_rules[col_name] = process_list
32
+ else:
33
+ agg_rules[col_name] = take_last
34
+
35
+ df_gb = df.groupby(cols).agg(agg_rules).reset_index()
36
+
30
37
  df_gb['pos_dest_nan'] = (df_gb['pos_dest_x'].isna() & df_gb['pos_dest_y'].isna()).astype(int)
31
38
  df_gb = df_gb.sort_values(by=['half', 'second', 'possession_number', 'pos_dest_nan']).reset_index(drop=True)
32
39
  return df_gb
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rustat-python-api
3
- Version: 0.5.8
3
+ Version: 0.5.9
4
4
  Summary: A Python wrapper for RuStat API
5
5
  Home-page: https://github.com/dailydaniel/rustat-python-api
6
6
  Author: Daniel Zholkovsky
@@ -3,10 +3,10 @@ rustat_python_api/config.py,sha256=eMvi1p8Cfvnbp6Cd4bBOwgehVN7thKnaQV5uzWyGZXM,1
3
3
  rustat_python_api/models_api.py,sha256=oHXEqeCupvZwjVEdoxf7W9LP7ELFKA8-9DuRXpQHLno,1701
4
4
  rustat_python_api/parser.py,sha256=PrGvN3vY0oczMsJxyUxBO0Yb1P03Moc74AgGYHYr_X8,10216
5
5
  rustat_python_api/pitch_control.py,sha256=c2uX7B3IMjdKFIb3QulO3188RfzgPwT4BdR8N1XYf_w,11643
6
- rustat_python_api/processing.py,sha256=46O7wUGv5boWf4A38zYinbtqEC7ke-BwTdEg589XQaw,2816
6
+ rustat_python_api/processing.py,sha256=WES2D77uu3ScpjN0nW8ozatHteCZJQmmF9WpHPgGfJo,2835
7
7
  rustat_python_api/urls.py,sha256=iJTD31T6OyXPAhmhViwFXVehrzwsOjBDONA1SIVc_40,1068
8
- rustat_python_api-0.5.8.dist-info/LICENSE,sha256=4Cohqg5p6Mq1xyrzdEX8AvFSA62GSVvapEOr2xK_tgY,57
9
- rustat_python_api-0.5.8.dist-info/METADATA,sha256=w8nXtOwc4t5YT8MIdbYE7Zt3YScKS9fneZBYPK74Iu0,1730
10
- rustat_python_api-0.5.8.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
11
- rustat_python_api-0.5.8.dist-info/top_level.txt,sha256=VK0hmkKZE9YThxolUcoE6JtGI67NFeKJMBLuet8kI4w,18
12
- rustat_python_api-0.5.8.dist-info/RECORD,,
8
+ rustat_python_api-0.5.9.dist-info/LICENSE,sha256=4Cohqg5p6Mq1xyrzdEX8AvFSA62GSVvapEOr2xK_tgY,57
9
+ rustat_python_api-0.5.9.dist-info/METADATA,sha256=Xwu5Q-R1tsAZ6r49Mii-LiCOtgWcirykl_EI_-0Oghw,1730
10
+ rustat_python_api-0.5.9.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
11
+ rustat_python_api-0.5.9.dist-info/top_level.txt,sha256=VK0hmkKZE9YThxolUcoE6JtGI67NFeKJMBLuet8kI4w,18
12
+ rustat_python_api-0.5.9.dist-info/RECORD,,