I have a dataframe that look like this.
key values
Interface InterfaceA
State Up
Line Status Up
ID 9000
Interface InterfaceB
State Down
Line Status Down
ID 9001
And I would like to transform it to become like this
Interface State Line Status ID
InterfaceA Up Up 9000
InterfaceB Down Down 9001
I've try to use loc to insert the column by column, but when it reaches 2nd columns
ValueError: cannot reindex from a duplicate axis
the above error appears.
final_df['Interface'] = commands_df.loc[commands_df['key'].str.contains('Interface'), 'values']
final_df['State'] = commands_df.loc[commands_df['key'].str.contains('State'), 'values'] <-- Error starts here
ValueError: cannot reindex from a duplicate axis