27 lines
873 B
Python
27 lines
873 B
Python
|
|
from demoparser2 import DemoParser
|
||
|
|
import os
|
||
|
|
import pandas as pd
|
||
|
|
|
||
|
|
demo_path = os.path.join(os.getcwd(), "data", "demos", "furia-vs-falcons-m1-inferno.dem")
|
||
|
|
parser = DemoParser(demo_path)
|
||
|
|
|
||
|
|
print("Listing events related to bomb...")
|
||
|
|
# Check events
|
||
|
|
# parse_events returns a list of tuples or dicts? Or a DataFrame?
|
||
|
|
# The previous error said 'list' object has no attribute 'head', so it returns a list of tuples/dicts?
|
||
|
|
# Wait, usually it returns a DataFrame. Let's check type.
|
||
|
|
events = parser.parse_events(["bomb_planted", "bomb_defused", "bomb_exploded", "round_start", "round_end"])
|
||
|
|
print(f"Type of events: {type(events)}")
|
||
|
|
|
||
|
|
if isinstance(events, list):
|
||
|
|
print(events[:5])
|
||
|
|
# Try to convert to DF
|
||
|
|
try:
|
||
|
|
df = pd.DataFrame(events)
|
||
|
|
print(df.head())
|
||
|
|
print(df['event_name'].value_counts())
|
||
|
|
except:
|
||
|
|
pass
|
||
|
|
else:
|
||
|
|
print(events.head())
|