Last active
January 7, 2021 04:17
-
-
Save gabecano4308/2ce49f9264de5b9d582bbe78927c3a3f to your computer and use it in GitHub Desktop.
for part 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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