Skip to content

Instantly share code, notes, and snippets.

@MarkusMueller-DS
Last active October 2, 2020 08:43
Show Gist options
  • Save MarkusMueller-DS/f9748e61b0143d4221eca900c3616a71 to your computer and use it in GitHub Desktop.
Save MarkusMueller-DS/f9748e61b0143d4221eca900c3616a71 to your computer and use it in GitHub Desktop.
Create a new column with a lambda function
# code creates a new column based on the quality of the wine using 6 as a threshold
df['rating'] = df['quality'].apply(lambda x: 'good' if x >= 6 else 'bad')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment