-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToday's Games NBA.py
40 lines (28 loc) · 1.32 KB
/
Today's Games NBA.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
39
40
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 24 10:13:00 2021
@author: norri
"""
import pandas as pd
from pysbr import *
from datetime import datetime
today = datetime.today().strftime('%Y-%m-%d')
today = datetime.strptime(today, '%Y-%m-%d')
# Get today's games
nba = NBA()
e = EventsByDate(nba.league_id, today)
cols = ['event id', 'event status',
'participants.1.source.abbreviation', 'participants.1.participant id',
'participants.2.source.abbreviation', 'participants.2.participant id']
games_today = e.dataframe()[cols]
games_today
games = []
for i in range(len(games_today)):
games.append((games_today['participants.1.source.abbreviation'][i], games_today['participants.2.source.abbreviation'][i]))
teams = {'ATL':'ATL', 'BKN': 'BRK', 'BOS': 'BOS', 'CHA': 'CHO', 'CHI': 'CHI',
'CLE': 'CLE', 'DAL': 'DAL', 'DEN': 'DEN', 'DET': 'DET', 'GSW': 'GSW',
'HOU': 'HOU', 'IND': 'IND', 'LAC': 'LAC', 'LAL': 'LAL', 'MEM': 'MEM',
'MIA': 'MIA', 'MIL': 'MIL', 'MIN': 'MIN', 'NOP': 'NOP', 'NYK': 'NYK',
'OKC': 'OKC', 'ORL': 'ORL', 'PHI': 'PHI', 'PHX': 'PHO', 'POR': 'POR',
'SAC': 'SAC', 'SAS': 'SAS', 'TOR': 'TOR', 'UTA': 'UTA', 'WAS': 'WAS'}
games = [(teams.get(team[0], team[0]), teams.get(team[1], team[1])) for team in games]