(file)
| 6 | |
| 7 | |
| 8 | def parse(file): |
| 9 | |
| 10 | number_of_kills = 5 |
| 11 | |
| 12 | parser = DemoParser(file) |
| 13 | df = pd.DataFrame(parser.parse_events("player_death", rounds=True)) |
| 14 | # end of "parser" after this its just pandas operations. |
| 15 | |
| 16 | # Remove warmup rounds. |
| 17 | df = df[df["round"] != 0] |
| 18 | |
| 19 | # Here we can include any other filters like weapons etc. |
| 20 | # df = df[df["weapon"] == "ak47"] |
| 21 | |
| 22 | all_rounds = [] |
| 23 | players = df["attacker_steamid"].unique() |
| 24 | |
| 25 | for player in players: |
| 26 | # slice players |
| 27 | player_df = df[df["attacker_steamid"] == player] |
| 28 | # Create df like this: ["round", "attacker_name", "total_kills"] |
| 29 | kills_per_round = player_df.groupby(["round", "attacker_name", "attacker_steamid"]).size( |
| 30 | ).to_frame(name='total_kills').reset_index() |
| 31 | # Get rounds with kills > n |
| 32 | kills_per_round = kills_per_round[kills_per_round["total_kills"] |
| 33 | >= number_of_kills] |
| 34 | # Add file name to df |
| 35 | kills_per_round["file"] = file |
| 36 | # Put all of those rounds in an output list |
| 37 | all_rounds.append(kills_per_round) |
| 38 | if len(df) > 0: |
| 39 | return pd.concat(all_rounds) |
| 40 | |
| 41 | |
| 42 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected