Skip to content

Commit 769b5b6

Browse files
committed
standings()
1 parent b0e862f commit 769b5b6

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ If you install manually, be sure to also install requests.
3232

3333
* `statsapi.roster()` - generate a list of players on a team's roster
3434

35+
* `statsapi.standings()` - generate a formatted list of standings for a given league/date
36+
3537
## Example Use
3638

3739
### Print the number of games won by the Oakland Athletics in 2018
@@ -84,3 +86,11 @@ then feed into max() to find the longest value and its length
8486
longest_team_name = max([x['name'] for x in statsapi.get('teams',{'sportIds':1,'activeStatus':'Yes','fields':'teams,name'})['teams']],key=len)
8587
print('The team with the longest name is %s, at %s characters.' % (longest_team_name, len(longest_team_name)))
8688
```
89+
90+
### Print the standings from July 4, 2018
91+
92+
Use `statsapi.standings()` with the `date` parameters
93+
94+
```
95+
print(statsapi.standings(date='07/04/2018'))
96+
```

statsapi/__init__.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,44 @@ def league_leaders(leaderCategories,leagueId=None,season=None):
659659
return "This function is not yet available."
660660

661661
def standings(leagueId=None,season=None,standingsTypes=None,date=None):
662-
"""Get standings for a given league and season.
662+
"""Get formatted standings for a given league and season.
663+
Will include division and wildcard standings
663664
664665
Format for date = 'MM/DD/YYYY', e.g. '04/24/2019'
666+
667+
Example use:
668+
669+
Print National League standings from 09/27/2008
670+
671+
print( statsapi.standings(leagueId=104,date='09/27/2008') )
672+
673+
Output:
674+
675+
National League Central
676+
Rank Team W L GB (E#) WC Rank WC GB (E#)
677+
1 Chicago Cubs 97 63 - - - - -
678+
2 Milwaukee Brewers 89 72 8.5 E 1 - -
679+
3 Houston Astros 85 75 12.0 E 3 3.5 E
680+
4 St. Louis Cardinals 85 76 12.5 E 4 4.0 E
681+
5 Cincinnati Reds 74 87 23.5 E 7 15.0 E
682+
6 Pittsburgh Pirates 66 95 31.5 E 11 23.0 E
683+
684+
National League West
685+
Rank Team W L GB (E#) WC Rank WC GB (E#)
686+
1 Los Angeles Dodgers 84 77 - - - - -
687+
2 Arizona Diamondbacks 81 80 3.0 E 6 8.0 E
688+
3 Colorado Rockies 74 87 10.0 E 8 15.0 E
689+
4 San Francisco Giants 71 90 13.0 E 10 18.0 E
690+
5 San Diego Padres 63 98 21.0 E 12 26.0 E
691+
692+
National League East
693+
Rank Team W L GB (E#) WC Rank WC GB (E#)
694+
1 Philadelphia Phillies 91 70 - - - - -
695+
2 New York Mets 89 72 2.0 E 2 - -
696+
3 Florida Marlins 83 77 7.5 E 5 5.5 E
697+
4 Atlanta Braves 72 89 19.0 E 9 17.0 E
698+
5 Washington Nationals 59 101 31.5 E 13 29.5 E
699+
665700
"""
666701
if not leagueId: leagueId = '103,104'
667702
params = {'leagueId':leagueId}

0 commit comments

Comments
 (0)