Can't get the function right

Hello community,

I just can’t figure out why the simple function I wrote is not working as I intended it. I would be very thankful if someone could nudge me in the right direction.

Best
Daniel

My Code:

cutoff_day = dt.datetime(2019, 10, 16)

def has_churned(date):
    if date < cutoff_day:
        1
    else:
        0

best_churn["churned"] = best_churn["trans_date"].apply(has_churned)

What I expected to happen:

Insert 1s and 0s in the “churned” column.

What actually happened:

No entries in the column

hey @daniel.baerenheuser

Welcome back to DQ!

The magic word here is return something from the function!

If you get it
   Do return
else
   also return!
1 Like

Hey @Rucha,

thank you very much for your fast reply!

Best
Daniel

1 Like