I have this data frame and want to remove rows based on this set of rules. If consecutive rows have the same 'area' and 'local' value and the 'group_name' is different then I want to remove the first row:
df = pd.DataFrame()
df['time'] = pd.date_range("2018-01-01", freq = "s", periods = 10)
df['area'] = [1,1,1,2,2,2,3,3,4,4]
df['local'] = [1,1,1,1,2,2,2,2,2,2]
df['group_name'] = [1,1,2,2,2,3,3,3,4,4]
df['value'] = [1,4,3,2,5,6,2,1,7,8]
The image above shows the table and I would want to remove row 1 and 4.
I have tried using duplicated()
on the subset of Area, Local and Group Name, but this not keep all the unique ones that I need
Please help me out!