Skip to content
Advertisement

Make a customized filter on a grouped dataframe with multiple conditions

Please find below my input/desired output :

INPUT

JavaScript

OUTPUT (desired)

JavaScript

The goal is firstly to have one line per Id in the output.
The output will be made based on a this simple statement :

JavaScript

This is what I’ve tried so far :

JavaScript

Do you have any suggestion/propositions, please ?
Any help we be so much appreciated !

Advertisement

Answer

Answer is completely edited – first filter only online rows, sorting by Date and remove duplicates by first Id:

JavaScript

Then filter not matched Id and sorting descending:

JavaScript

Last join both Dataframes:

JavaScript

Original solution should be changed:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement