Skip to content

Instantly share code, notes, and snippets.

@ShayanRiyaz
Created April 24, 2020 10:31
Show Gist options
  • Save ShayanRiyaz/52de827d93a9c51f7e00a45a0368eab9 to your computer and use it in GitHub Desktop.
Save ShayanRiyaz/52de827d93a9c51f7e00a45a0368eab9 to your computer and use it in GitHub Desktop.
# one hot encoding
la_onehot = pd.get_dummies(la_venues[['Venue Category']], prefix="", prefix_sep="")
# add neighbourhood column back to data frame
la_onehot['Neighbourhood'] = la_venues['Neighbourhood']
# move neighbourhood column to the first column
fixed_columns = [la_onehot.columns[-1]] + list(la_onehot.columns[:-1])
la_onehot = la_onehot[fixed_columns]
la_onehot.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment