Hi! I’m on the Predict Credit Card Fraud project, and I’m having some issues with step 3:
- We have a lot of information about the
type
of transaction we are looking at. Let’s create a new column calledisPayment
that assigns a1
whentype
is “PAYMENT” or “DEBIT”, and a0
otherwise.
The hint is as follows:
You can create a new column for a
pandas
DataFrame like this:df['new_column'] = value
You can filter a DataFrame for specific values like this:
df[df['filter_column'] == value]
My code:
if transactions[transactions[‘type’] in (“PAYMENT”, “DEBIT”)]:
transactions[‘isPayment’] = 1
else:
transactions[‘isPayment’] = 0
Error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Am I just supposed to ignore the hint and guess with the DataFrame methods?