I would like to analyze statistics per cars which were repairs and which are new. Data sample is:
Name IsItNew ControlDate
Car1 True 31/01/2018
Car2 True 28/02/2018
Car1 False 15/03/2018
Car2 True 16/04/2018
Car3 True 30/04/2018
Car2 False 25/05/2018
Car1 False 30/05/2018
So, I should groupby
by Name and if there is a False
in IsItNew
column I should set False
and the first date, when False
was happened.
I tried groupby
with nunique()
:
df = df.groupby(['Name','IsItNew', 'ControlDate' ])['Name'].nunique()
But, it returns count of unique items in each group.
How can I receive only grouped unique items without any count?
Actual result is:
Name IsItNew ControlDate
Car1 True 31/01/2018 1
False 15/03/2018 1
30/05/2018 1
Car2 True 28/02/2018 1
16/04/2018 1
False 25/05/2018 1
Car3 True 30/04/2018 1
Expected Result is:
Name IsItNew ControlDate
Car1 False 15/03/2018
Car2 False 25/05/2018
Car3 True 30/04/2018
I'd appreciate for any idea. Thanks)