Lets say I have a data frame like this
ID,Time1,Value1,Time2,Value2,Time3,Value3
1,2,1.1,3,1.2,4,1.3
1,5,2.1,6,2.2,7,2.3
And the expected dataframe is this
ID,Time,Value
1,2,1.1
1,3,1.2
1,4,1.3
1,5,2.1
1,6,2.2
1,7,2.3
If the row has unique id, the pd.wide_to_long
works perfectly in such case.
df = pd.wide_to_long(df, ['Time',Value],'ID','value', sep='', suffix='.+')\
.reset_index()\
.sort_values(['ID', 'Time'])\
.drop('value', axis=1)\
.dropna(how='any')
but how to fix in such situation, if row's ID is not unique