Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created February 6, 2021 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyishaR/8eeb86d7b1d60ca53a51b9ca6d4d9503 to your computer and use it in GitHub Desktop.
Save AyishaR/8eeb86d7b1d60ca53a51b9ca6d4d9503 to your computer and use it in GitHub Desktop.
dummy_columns = ['Location', 'WindGustDir', 'WindDir9am', 'WindDir3pm']
for column in dummy_columns:
dummy_loc = pd.get_dummies(df[column], prefix = column, drop_first = True)
for c in dummy_loc.columns:
df[c] = dummy_loc[c]
del dummy_loc
df = df.drop(columns = dummy_columns)
df = df.drop(columns = ['RainToday', 'Date'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment