Skip to content

Commit

Permalink
fixed stupid dataframe merge error i created with the match type filter
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieVeitch committed Dec 19, 2022
1 parent 598fe0f commit 2861d3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions analysis/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def preprocess(games: pd.DataFrame) -> pd.DataFrame:

ranked_games.set_index('matchID', inplace=True)
ranked_games = ranked_games.loc[has_even_teams.intersection(has_damage).intersection(has_highlander)]
ranked_games = games.copy().set_index('matchID')

recent_names = player_names(games=ranked_games)
ranked_games['name'] = ranked_games['uid'].replace(recent_names)
Expand Down
9 changes: 7 additions & 2 deletions analysis/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def get_game_type(games: pd.DataFrame) -> pd.DataFrame:
:return:
"""
team_size = games.groupby(['matchID', 'round', 'team'])['name'].count()
team_size = team_size.rename('team_size').reset_index(level=[1, 2])['team_size']
team_size = team_size.rename('team_size').reset_index()

return pd.merge(games, team_size, left_index=True, right_index=True).reset_index()
return pd.merge(
games,
team_size,
left_on=['matchID', 'round', 'team'],
right_on=['matchID', 'round', 'team']
)
2 changes: 1 addition & 1 deletion spreadsheet/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def load_game_data() -> pd.DataFrame:

view_games = ranked_games.groupby(state.group_columns)[state.data_columns].agg(state.agg_func)
round_count = ranked_games.groupby(
state.group_columns)["name"].count().squeeze().astype(int).rename("rounds_played")
state.group_columns).count()["team_size"].squeeze().astype(int).rename("rounds_played")
view_games = pd.concat([view_games, round_count], axis=1)
view_games = round(view_games, 2)

Expand Down

0 comments on commit 2861d3a

Please sign in to comment.