Skip to content
Advertisement

Fill np.nan with values based on other columns

I try to match the offer_id to the corresponding transaction. This is the dataset:

JavaScript

The rule is that when the offer is viewed, the transaction belongs to this offer id. If the offer is reveived, but not viewed, the transaction does not belong to the offer id. I hope the time variable makes it clear. This is the desired result:

JavaScript

Advertisement

Answer

Example code:

JavaScript

Outputs:

JavaScript
Advertisement