-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProportionalAge.py
34 lines (31 loc) · 999 Bytes
/
ProportionalAge.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
import time
import numpy as np
import pandas as pd
from collections import Counter
def main():
df = pd.read_csv(r'C:\Users\Mitch\Projects\Golf\Data\full_data.csv',encoding='latin1')
df = df[['Golfer','Date','Score']]
golfers = list(set(list(df['Golfer'])))
golfers_dfs = [df.loc[df['Golfer'] == x] for x in golfers]
dfs = []
length = 0
for x in golfers_dfs:
temp_df = x.sort_values(by='Date')
if temp_df.shape[0] > length:
length = temp_df.shape[0]
temp_df = temp_df.reset_index(drop=True)
dfs += [temp_df]
rounds = {key: [] for key in range(length-1)}
for x in dfs:
for y in rounds.keys():
try:
rounds[y] += [x['Score'][y]]
except KeyError:
continue
scores = pd.DataFrame(dict([(k,pd.Series(v)) for k,v in rounds.items()]))
print(scores)
if __name__ == "__main__":
start = time.time()
main()
end = time.time()
print(end-start)