loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7359864008818133","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KIiIiCkFuYWx5emUgTkJBIHBsYXlvZmZzIGZpcnN0IHJvdW5kIGRhdGEgKDIwMDh+MjAxOCkKQ29weXJpZ2h0IGJ5IEphcnZ1cyBDaGVuIC8gaHR0cHM6Ly9qYXJ2dXMubmV0CiIiIgoKaW1wb3J0IG51bXB5IGFzIG5wCmltcG9ydCBwaWNrbGUKCiMgcGFyYW1ldGVycwp3b3JsZCA9ICfmnbEnICAgICAgICAjICfmnbEnIG9yICfopb8nCmZpcnN0X2hvbWUgPSAyICAgICAgIyDns7vliJfos73nrKzkuIDmiLDvvIznlLHnrKzlub7poIbkvY3ngrrkuLvloLQKZ2FtZV9yb3VuZCA9IDUgICAgICAjIOezu+WIl+izveesrOW5vuaIsO+8jDF+NwoKIyBpbXBvcnQgZGF0YQp3aXRoIG9wZW4oJy4vbWF0Y2hfbGlzdC5kYXRhJywgJ3JiJykgYXMgZnA6CiAgICBtYXRjaF9saXN0ID0gcGlja2xlLmxvYWQoZnApCgojIG1haW4KaG9tZV93aW5fY291bnQgPSAwCmF3YXlfd2luX2NvdW50ID0gMApob21lX3dpbl9zY29yZSA9IFtdCmF3YXlfd2luX3Njb3JlID0gW10Kd2luX2xpc3QgPSBbXQp5ZWFyX2xpc3QgPSBbXQogCmZvciBtYXRjaCBpbiBtYXRjaF9saXN0OgoKICAgIGlmIGxlbihtYXRjaCkgPj0gZ2FtZV9yb3VuZDoKICAgICAgICAKICAgICAgICBpZiBtYXRjaFtnYW1lX3JvdW5kLTFdWyd3b3JsZCddID09IHdvcmxkIGFuZCBtYXRjaFtnYW1lX3JvdW5kLTFdWydmaXJzdF9ob21lJ10gPT0gZmlyc3RfaG9tZToKICAgICAgICAKICAgICAgICAgICAgaWYgbWF0Y2hbZ2FtZV9yb3VuZC0xXVsnd2luJ10gPT0gJ2hvbWUnOgogICAgICAgICAgICAgICAgaG9tZV93aW5fY291bnQgPSBob21lX3dpbl9jb3VudCArIDEKICAgICAgICAgICAgICAgIGhvbWVfd2luX3Njb3JlLmFwcGVuZCggbWF0Y2hbZ2FtZV9yb3VuZC0xXVsnaG9tZV9taW51c19hd2F5J10gKQogICAgICAgICAgICAgICAgCiAgICAgICAgICAgIGlmIG1hdGNoW2dhbWVfcm91bmQtMV1bJ3dpbiddID09ICdhd2F5JzoKICAgICAgICAgICAgICAgIGF3YXlfd2luX2NvdW50ID0gYXdheV93aW5fY291bnQgKyAxCiAgICAgICAgICAgICAgICBhd2F5X3dpbl9zY29yZS5hcHBlbmQoIC1tYXRjaFtnYW1lX3JvdW5kLTFdWydob21lX21pbnVzX2F3YXknXSApCiAgICAgICAgICAgIAogICAgICAgICAgICB3aW5fbGlzdC5hcHBlbmQobWF0Y2hbZ2FtZV9yb3VuZC0xXVsnaG9tZV9taW51c19hd2F5J10pCiAgICAgICAgICAgIHllYXJfbGlzdC5hcHBlbmQobWF0Y2hbZ2FtZV9yb3VuZC0xXVsneWVhciddKQogICAgICAgICAgICAKaG9tZV93aW5fYXZnID0gbnAucm91bmQobnAubWVhbihob21lX3dpbl9zY29yZSksIDEpCmF3YXlfd2luX2F2ZyA9IG5wLnJvdW5kKG5wLm1lYW4oYXdheV93aW5fc2NvcmUpLCAxKQoKcHJpbnQoJ0hvbWU6JywgaG9tZV93aW5fY291bnQsICcsYXZnIHNjb3JlOicsIGhvbWVfd2luX2F2ZykKcHJpbnQoJ0F3YXk6JywgYXdheV93aW5fY291bnQsICcsYXZnIHNjb3JlOicsIGF3YXlfd2luX2F2ZykKcHJpbnQoJ1llYXI6JywgeWVhcl9saXN0KQpwcmludCgnSG9tZS1Bd2F5OicsIHdpbl9saXN0KQ=="},"asBuffer":null},"loaded":true}}
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
# -*- coding: utf-8 -*-
"""
Analyze NBA playoffs first round data (2008~2018)
Copyright by Jarvus Chen / https://jarvus.net
"""

import numpy as np
import pickle

# parameters
world = '東'        # '東' or '西'
first_home = 2      # 系列賽第一戰,由第幾順位為主場
game_round = 5      # 系列賽第幾戰,1~7

# import data
with open('./match_list.data', 'rb') as fp:
    match_list = pickle.load(fp)

# main
home_win_count = 0
away_win_count = 0
home_win_score = []
away_win_score = []
win_list = []
year_list = []
 
for match in match_list:

    if len(match) >= game_round:
        
        if match[game_round-1]['world'] == world and match[game_round-1]['first_home'] == first_home:
        
            if match[game_round-1]['win'] == 'home':
                home_win_count = home_win_count + 1
                home_win_score.append( match[game_round-1]['home_minus_away'] )
                
            if match[game_round-1]['win'] == 'away':
                away_win_count = away_win_count + 1
                away_win_score.append( -match[game_round-1]['home_minus_away'] )
            
            win_list.append(match[game_round-1]['home_minus_away'])
            year_list.append(match[game_round-1]['year'])
            
home_win_avg = np.round(np.mean(home_win_score), 1)
away_win_avg = np.round(np.mean(away_win_score), 1)

print('Home:', home_win_count, ',avg score:', home_win_avg)
print('Away:', away_win_count, ',avg score:', away_win_avg)
print('Year:', year_list)
print('Home-Away:', win_list)