Reputation: 83
I am currently having a problem where I am splitting a column into two separate columns. When I perform my code it runs without any errors, but the dataframe is still the same. I'm not sure where my mistake is.
url = 'https://www.teamrankings.com/nba/player/clint-capela/game-log'
html = requests.get(url).content
get_log = pd.read_html(html)
players_log = get_log[0]
game_log = players_log.head()
players_log.info()
players_log.join(players_log['FGM-FGA'].str.split('-', 1, expand=True).rename(columns={0:'A', 1:'B'}))
players_log.info()
print(game_log)
Upvotes: 0
Views: 34
Reputation: 4459
Pandas operations by default doesn't change the original dataframe and returns a new object, so
players_log = players_log.join(players_log['FGM-FGA'].str.split('-', 1, expand=True).rename(columns={0:'A', 1:'B'}))
should do it
Upvotes: 2