File size: 1,345 Bytes
d757142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from nba_api.stats.endpoints import leaguestandings
import pandas as pd

print("🏆 CONFERENCE STANDINGS")
print("=" * 50)

try:
    # Fetch Data
    standings = leaguestandings.LeagueStandings()
    df = standings.standings.get_data_frame()
    
    # Organize columns
    cols = ['Conference', 'PlayoffRank', 'TeamCity', 'TeamName', 'WINS', 'LOSSES', 'WinPCT']
    df = df[cols]

    # Process West
    print("\nWestern Conference")
    print("-" * 50)
    print(f"{'#':<3} | {'TEAM':<20} | {'W':<3} | {'L':<3} | {'PCT'}")
    print("-" * 50)
    
    west = df[df['Conference'] == 'West'].sort_values(by='PlayoffRank')
    for _, row in west.iterrows():
        team = f"{row['TeamCity']} {row['TeamName']}"
        print(f"{row['PlayoffRank']:<3} | {team:<20} | {row['WINS']:<3} | {row['LOSSES']:<3} | {row['WinPCT']:.3f}")

    # Process East
    print("\n\nEastern Conference")
    print("-" * 50)
    print(f"{'#':<3} | {'TEAM':<20} | {'W':<3} | {'L':<3} | {'PCT'}")
    print("-" * 50)
    
    east = df[df['Conference'] == 'East'].sort_values(by='PlayoffRank')
    for _, row in east.iterrows():
        team = f"{row['TeamCity']} {row['TeamName']}"
        print(f"{row['PlayoffRank']:<3} | {team:<20} | {row['WINS']:<3} | {row['LOSSES']:<3} | {row['WinPCT']:.3f}")

except Exception as e:
    print(f"Error fetching standings: {e}")