-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetolddata.py
38 lines (20 loc) · 900 Bytes
/
getolddata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import csv
import pandas as pd
fields = ['match_id','radiant_win']
df = pd.read_csv('match.csv',skipinitialspace=True, usecols=fields)
df['radiant_win'] = df['radiant_win'].astype(int)
fields2 = ['match_id','hero_id']
heros = pd.read_csv('players.csv',skipinitialspace=True, usecols=fields2)
with open('oldmatchdata.csv', 'w') as f:
write = csv.writer(f)
write.writerow(['radiant_win','rhero1','rhero2','rhero3','rhero4','rhero5','dhero1','dhero2','dhero3','dhero4','dhero5'])
for match in df.match_id:
herosPlayed = heros.loc[heros['match_id'] == match]
heroslist = herosPlayed['hero_id'].values.tolist()
dlist = df['radiant_win'].values[match].tolist()
fList = [dlist] + heroslist
with open('oldmatchdata.csv', 'a') as f:
write = csv.writer(f)
write.writerow(fList)
# for match in df.match_id:
# heros =