Please find attached snap and provide me how to reach to a solution of desired output mentioned in image description?
Code to generate input dataframe:
df = pd.DataFrame({'timestamp':pd.date_range('2022-04-30 00:00:00', periods=19, freq='S'),
'fault_code':['A']*4+['B']*4+['A']*2+['C']*5+['B']*2+['A']*2})
