df = pd.DataFrame({'Unique_id':[1,1,2,2,3,3,3,3],
'Car_history':[0,1,0,1,0,1,0,1],
'Value':[1000,1500,1000,1200,800,700,1300,1700],
'Ob_id':[0,1,0,2,0,3,0,4]})
df["Count_ob"] = df.Ob_id[::-1].cumsum()[::-1] # <=== this do the trick!!!
df["Count_ob"] = df["Count_ob"].max() - df["Count_ob"]
df = df.groupby("Count_ob")[["Unique_id","Car_history","Value","Ob_id"]].agg({'Unique_id':'max',
'Car_history':'sum',
'Value':'sum',
'Ob_id':'sum'}).reset_index(drop=True)
df['Value'] = df.groupby('Unique_id')['Value'].cumsum().values