I tried to merge the two columns begin and end to Flag and Timestamp with this piece of code:
print(df_DisponibilityAlarm.shape)
df_DisponibilityAlarm = (df_DisponibilityAlarm.stack()
.rename_axis([None, 'Flag'])
.reset_index(level=1, name='Timestamp'))
print(df_DisponibilityAlarm.shape)
The result is :
begin end
0 NaN 2019-10-21 07:48:28.272688
1 NaN 2019-10-21 07:48:28.449916
2 2019-10-21 07:48:26.740378 NaN
3 2019-10-21 07:48:26.923764 NaN
4 NaN 2019-10-21 07:48:41.689466
5 2019-10-21 07:48:37.306045 NaN
6 NaN 2019-10-21 07:58:00.774449
7 2019-10-21 07:57:59.223986 NaN
8 NaN 2019-10-21 08:32:37.004455
9 2019-10-21 08:32:35.755252 NaN
(13129, 2)
(13140, 2)
Flag Timestamp
0 end 2019-10-21 07:48:28.272688
1 end 2019-10-21 07:48:28.449916
2 begin 2019-10-21 07:48:26.740378
3 begin 2019-10-21 07:48:26.923764
4 end 2019-10-21 07:48:41.689466
5 begin 2019-10-21 07:48:37.306045
6 end 2019-10-21 07:58:00.774449
7 begin 2019-10-21 07:57:59.223986
8 end 2019-10-21 08:32:37.004455
9 begin 2019-10-21 08:32:35.755252
It works ! But when I looked closely, I see when I use "stack()" the number of the rows increase... I don't understand why, can you explain me please ? I need this to validate my starting hypothesis.