Skip to content
Advertisement

Tag: dataframe

How to calculate cumulative subtraction with a threshold and reset the subtraction after threshold within groups in pandas dataframe in python?

This is a dataframe, with 4 columns. The primary dataframe contains two columns, trip and timestamps, and I calculated ‘TimeDistance’ which is the difference between rows of timestamps, and ‘cum’ which is the cumulative sum over TimeDistance column. in order to reach my goal, but I could not. this is the output: This output is not my desired output, I

How to assign values to multiple columns using conditions for values from other multiple columns?

Dataset is something like this (there will be duplicate rows in the original): Code: Output should be this: Code: ‘series1′ column values starts row by row as 0, 1, 2, and so on but resets to 0 when: ’email_ID’ column value changes. ‘screen’ column value == ‘rewardapp.PaymentFinalConfirmationActivity’ ‘series2’ column values starts with 0 and increments by 1 whenever ‘series1’ resets.

Advertisement