vendredi 6 mars 2020

Modify excel if function with cumulative sum into python dataframe column

I wan't to rewrite function from excel to column in python dataframe.

the function is

A2=IF((SUM($P$2:P2)+HelpTables!$D$2)<=500000,10,IF((SUM($P$2:P2)+HelpTables!$D$2)<=1000000,20,30))

It is second row, the third looks like

A3=IF((SUM($P$2:P3)+HelpTables!$D$2)<=500000,10,IF((SUM($P$2:P3)+HelpTables!$D$2)<=1000000,20,30))

and so on.

The HelpTables!$D$2 is only number, but I have to keep it as variables.

I want to apply this function into dataframe in python script, but I don't know how do it. Let's say Column P is names as 'Price' in dataframe, Column A as 'Line' and the variable is as float64 variable named as 'SUM'

Can you please help me how o do it? Thank you.

Aucun commentaire:

Enregistrer un commentaire