Predict Credit Card Fraud hint not working

Hi! I’m on the Predict Credit Card Fraud project, and I’m having some issues with step 3:

  1. We have a lot of information about the type of transaction we are looking at. Let’s create a new column called isPayment that assigns a 1 when type is “PAYMENT” or “DEBIT”, and a 0 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?

1 Like

@dentarthurdent42 I am assuming you dont still need help with this, but did you get the transactions 1-3 to work with a prediction? I can’t get it working and cant figure out why :confused:

This is what I used:

# Create isPayment field

transactions['isPayment'] = 0

transactions['isPayment'][transactions['type'] == 'DEBIT'] = 1

transactions['isPayment'][transactions['type'] == 'PAYMENT'] = 1

# Create isMovement field

transactions['isMovement'] = 0

transactions['isMovement'][transactions['type'] == 'CASH_OUT'] = 1

transactions['isMovement'][transactions['type'] == 'TRANSFER'] = 1

I don’t remember what I did at this point I am so far away from there, like half way through the AI/ML Engineering career path, but I believe I ended up getting it working somehow having it filter through for both at the same time. I think it was using .loc( ). I might go back and check when I have the time so thz for answering.

Also lol at it saying you answered your own question on the first post, got rly confused by that for a second.