0

If I have the table below

html_url = "https://www.basketball-reference.com/leagues/NBA_2022_per_game.html"
nba_tables = pd.read_html(html_url)
len(nba_tables)
nba = nba_tables[0]
nba.head(30)

How would I create a new column called column called "Conference", where if a players team is DAL, DEN, GSW, HOU, LAC, LAL, MEM, MIN, NOP, OKC, PHO, POR, SAC, SAS, or UTA the value in the "Conference" column would be "WEST", and any other team would be labeled "EAST".

Thanks

MKHN15
  • 11
  • 1
  • 1
    `nba['CONF'] = nba['Tm'].apply(lambda x: 'East' if x in ['DAL', 'DEN', 'GSW', 'HOU', 'LAC', 'LAL', 'MEM', 'MIN', 'NOP', 'OKC', 'PHO', 'POR', 'SAC', 'SAS', 'UTA'] else 'West')` – Derek O Dec 25 '21 at 22:03

0 Answers0