Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created February 20, 2021 08:01
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/75d9511272d2b57c7332704fc48f8f44 to your computer and use it in GitHub Desktop.
Save AyishaR/75d9511272d2b57c7332704fc48f8f44 to your computer and use it in GitHub Desktop.
colours = ['Blu', 'Whit', 'Yellow', 'Orang', 'Red'] # using root word of colours as the spelling can differ while specifying shades
df[colours] = 0
for c in colours:
df.loc[df['Star color'].str.contains(c, case = False), c]=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment