MCPcopy Create free account
hub / github.com/LaihoE/Python-demoparser / parse

Function parse

examples/find_all_aces/find_epic_kill_parallel.py:8–39  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

6
7
8def 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
42if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

parse_eventsMethod · 0.95
DemoParserClass · 0.85

Tested by

no test coverage detected