Skip to content

Instantly share code, notes, and snippets.

@wibowotangara
Created January 19, 2024 09:08
Show Gist options
  • Save wibowotangara/a71fb02df441b41b2f56e187445c2809 to your computer and use it in GitHub Desktop.
Save wibowotangara/a71fb02df441b41b2f56e187445c2809 to your computer and use it in GitHub Desktop.
import numpy as np
conditions = [
(df['loan_status'].isin(['Fully Paid', 'Does not meet the credit policy. Status:Fully Paid'])),
(df['loan_status'].isin(['Charged Off', 'Late (31-120 days)', 'In Grace Period', 'Late (16-30 days)',
'Default', 'Does not meet the credit policy. Status:Charged Off']))
]
values = ['good','bad']
df['loan_label'] = np.select(conditions, values, default='Unknown')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment