How can I count the number of cases for each record

Hi guys,

In my dataset, I have a record of credit card transactions. I am trying to create a new column that has the number of times a card has been flagged as fraud.

So if I have a card 11111, and this card has had three transactions flagged as fraud in the entire dataset, I want that column to have the value of three in every row (transaction record) that has this card.

I feel like this should be possible, but I don’t know how to go about it.

Your help is appreciated!

Hi @TosinLitics welcome to the forum. You can create the count of the number of frauds With a Groupby node. After that using the Joiner node, join your original table with the table of the number of frauds you just created using Left Outer Join as mode and the credit card number as Key.

Hope it is clear.


Thanks, @iperez!

Your solution helped get me going!

The only limit is that the GroupBy node was counting all the appearance of a credit card in the dataset of transactions, it wasn’t counting only fraud cases.

To tackle this I used two filter nodes to separate the dataset into fraud and non-fraud cases. For the fraud cases, I aggregated by counting the cases. For the non-fraud cases, I just used the first value as the method of aggregation. This way, I got zeros for all credit cards.

Next, I used a concatenate node to join the two resulting GroupBy tables together, then I did the join as you suggested.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.