2.0.1: Updated solo
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1001,7 +1001,6 @@ class FeatureService:
|
|||||||
WHERE match_id IN ({match_id_ph}) AND match_team_id > 0
|
WHERE match_id IN ({match_id_ph}) AND match_team_id > 0
|
||||||
GROUP BY match_id, match_team_id
|
GROUP BY match_id, match_team_id
|
||||||
"""
|
"""
|
||||||
# Split match_ids into chunks if too many
|
|
||||||
chunk_size = 900
|
chunk_size = 900
|
||||||
party_sizes_list = []
|
party_sizes_list = []
|
||||||
for i in range(0, len(match_ids), chunk_size):
|
for i in range(0, len(match_ids), chunk_size):
|
||||||
@@ -1012,33 +1011,29 @@ class FeatureService:
|
|||||||
|
|
||||||
if party_sizes_list:
|
if party_sizes_list:
|
||||||
df_party_sizes = pd.concat(party_sizes_list)
|
df_party_sizes = pd.concat(party_sizes_list)
|
||||||
|
|
||||||
# Merge party size to base data
|
|
||||||
df_base_party = df_base.merge(df_party_sizes, on=['match_id', 'match_team_id'], how='left')
|
df_base_party = df_base.merge(df_party_sizes, on=['match_id', 'match_team_id'], how='left')
|
||||||
|
else:
|
||||||
|
df_base_party = df_base.copy()
|
||||||
|
|
||||||
|
df_base_party['party_size'] = df_base_party['party_size'].fillna(1)
|
||||||
|
df_base_party = df_base_party[df_base_party['party_size'].isin([1, 2, 3, 4, 5])]
|
||||||
|
|
||||||
# Calculate Stats per Party Size (1-5)
|
|
||||||
# We want columns like party_1_win_rate, party_1_rating, party_1_adr
|
|
||||||
party_stats = df_base_party.groupby(['steam_id_64', 'party_size']).agg({
|
party_stats = df_base_party.groupby(['steam_id_64', 'party_size']).agg({
|
||||||
'is_win': 'mean',
|
'is_win': 'mean',
|
||||||
'rating': 'mean',
|
'rating': 'mean',
|
||||||
'adr': 'mean'
|
'adr': 'mean'
|
||||||
}).reset_index()
|
}).reset_index()
|
||||||
|
|
||||||
# Pivot
|
|
||||||
pivoted_party = party_stats.pivot(index='steam_id_64', columns='party_size').reset_index()
|
pivoted_party = party_stats.pivot(index='steam_id_64', columns='party_size').reset_index()
|
||||||
|
|
||||||
# Flatten and rename
|
|
||||||
new_party_cols = ['steam_id_64']
|
new_party_cols = ['steam_id_64']
|
||||||
for col in pivoted_party.columns:
|
for col in pivoted_party.columns:
|
||||||
if col[0] == 'steam_id_64': continue
|
if col[0] == 'steam_id_64': continue
|
||||||
metric, size = col
|
metric, size = col
|
||||||
if size in [1, 2, 3, 4, 5]:
|
if size in [1, 2, 3, 4, 5]:
|
||||||
# metric is is_win, rating, adr
|
|
||||||
metric_name = 'win_rate' if metric == 'is_win' else metric
|
metric_name = 'win_rate' if metric == 'is_win' else metric
|
||||||
new_party_cols.append(f"party_{int(size)}_{metric_name}")
|
new_party_cols.append(f"party_{int(size)}_{metric_name}")
|
||||||
|
|
||||||
# Handle MultiIndex column flattening properly
|
|
||||||
# The pivot creates MultiIndex. We need to construct a flat DataFrame.
|
|
||||||
flat_data = {'steam_id_64': pivoted_party['steam_id_64']}
|
flat_data = {'steam_id_64': pivoted_party['steam_id_64']}
|
||||||
for size in [1, 2, 3, 4, 5]:
|
for size in [1, 2, 3, 4, 5]:
|
||||||
if size in pivoted_party['is_win'].columns:
|
if size in pivoted_party['is_win'].columns:
|
||||||
|
|||||||
Reference in New Issue
Block a user