Skip to content

Instantly share code, notes, and snippets.

@gabecano4308
Last active January 7, 2021 04:17
Show Gist options
  • Save gabecano4308/2ce49f9264de5b9d582bbe78927c3a3f to your computer and use it in GitHub Desktop.
Save gabecano4308/2ce49f9264de5b9d582bbe78927c3a3f to your computer and use it in GitHub Desktop.
for part 2
# Function changes all object columns that should be numeric to an int or float
def obj_to_num(nba_df):
str_cols = ['Name', 'Team', 'Twitter Handle', 'Position', 'Height']
for i in nba_df.columns:
if i not in str_cols:
nba_df[i] = pd.to_numeric(nba_df[i])
print(nba_df.dtypes)
obj_to_num(all_nba_players_2021)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment