g = (df.url != df.url.shift()).cumsum()
print(df.groupby([df.ID, df.date, g], sort=False).agg({'active_seconds':
    'sum', 'url': 'first'}).reset_index(level='url', drop=True).reset_index(
    ).reindex(columns=df.columns))
Pandas: union duplicate strings