-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.py
More file actions
77 lines (72 loc) · 2.26 KB
/
playground.py
File metadata and controls
77 lines (72 loc) · 2.26 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from pybaseball import schedule_and_record
import pandas as pd
abbreviations = ["ARI",
"ATL",
"BAL",
"BOS",
"CHW",
"CHC",
"CIN",
"CLE",
"COL",
"DET",
"HOU",
"KC",
"LAA",
"LAD",
"MIA",
"MIL",
"MIN",
"NYM",
"NYY",
"OAK",
"PHI",
"PIT",
"SD",
"SF",
"SEA",
"STL",
"TB",
"TEX",
"TOR",
"WSN"]
for team in abbreviations:
print(team)
try:
df = pd.read_pickle("/Users/devonallison/code/Monopoly/src/main/thesis/data/schedules/" + team + ".pkl")
for i in range(1, len(df) + 1):
dfdate = df["Date"][i]
new_date = dfdate.split(",")[1].strip().split()
month = new_date[0]
day = new_date[1]
if month == "Apr":
month_int = "04"
elif month == "May":
month_int = "05"
elif month == "Jun":
month_int = "06"
elif month == "Jul":
month_int = "07"
elif month == "Aug":
month_int = "08"
elif month == "Sep":
month_int = "09"
elif month == "Oct":
month_int = "10"
else:
raise Exception("Unknown month = {}".format(month))
if len(day) == 2:
day_int = day
elif len(day) == 1:
day_int = "0" + day
else:
raise Exception("Unknown day format = {}".format(day))
to_write = "2017-{}-{}".format(month_int, day_int)
df["Date"][i] = to_write
df.to_pickle("/Users/devonallison/code/Monopoly/src/main/thesis/data/schedules/" + team + "2.pkl")
except ValueError:
print("Couldn't find data " + team)
#print(data)
# import pandas as pd
# df = pd.read_pickle("/Users/devonallison/code/Monopoly/src/main/thesis/PHI.pkl")
# print(df)