mardi 13 août 2019

Use pandas assign with Inline if-statement

I have a dataframe 'df_dorn_Zeit' in which i want to add a new column based on the condition if the value in column 'Counter' changes from one row to the next. And I am out of solutions or i miss something major.

I tried the solution in this link:

Inline if statement conditional pandas assign value to new column

but it does not work.

here is my code:

df_dorn_v=df_dorn_Zeit.assign(Dorn_dif_mm=np.where(df_dorn_Zeit.Counter= df_dorn_Zeit.Counter.shift(),df_dorn_Zeit.Pos_Dorn.diff(), 0))

I get the error message:

SyntaxError: keyword can't be an expression

Aucun commentaire:

Enregistrer un commentaire