vendredi 7 mai 2021

Beginner Python loops

I have a dataset with 'Date' and 'Installs', and I want to add a new column 'Payout'. But the 'Payout' differs based on the 'Date' and 'Installs. eg. 2021-04-09, 2 and in the 'Payout' column, should be $0.25 * 2 eg. 2021-04-22, 5 and in the 'Payout' column, should be $0.4 * 5 I have tried the following function, but it returns None. What part is wrong?

def payout():
PO = []
for i in PO:
    if df_to_ef_aos[df_to_ef_aos['Date'] < '2021-04-09']:
        return 0.25
    elif '2021-04-09' < df_to_ef_aos[df_to_ef_aos['Date'] < '2021-04-21']:
        return 0.3
    elif df_to_ef_aos[df_to_ef_aos['Date'] > '2021-04-21']:
        return 0.45
    PO.append[i]

print(payout())

Aucun commentaire:

Enregistrer un commentaire