I have data in pandas dataframes in the form
|timestamp|bssid|dbm|other cols|
|---------|-----|---|----------|
|12345678 |mac 1|-50|text |
|---------|-----|---|----------|
|87654321 |mac 2|-70|text 2 |
|---------|-----|---|----------|
I am trying to transform it into
|timestamp|mac 1|mac 2|
|---------|-----|-----|
|12345678 |-50 | NaN |
|---------|-----|-----|
|87654321 | NaN | -70 |
|---------|-----|-----|
I have so far tried to use df.pivot(index='timestamp', columns='bssid', values='dbm') but this results in
|bssid |mac 1|mac 2|
|----------|-----|-----|
|timestamp | | |
|----------|-----|-----|
|12345678 | -50 | NaN |
|----------|-----|-----|
|87654321 | NaN | -70 |
|----------|-----|-----|
My question is if there is either a different way to generate the table I want, or how I can transform the table I now have into the table I want.
Additional info about my last table: df.columns yields Index(['mac 1', 'mac 2', ..., 'mac n'], dtype='object', name='bssid', length=163)
df.axes yields [Int64Index([12345678, 87654321], dtype='int64', name='timestamp'), Index(['mac 1', 'mac 2', ..., 'mac n'], dtype='object', name='bssid', length=163)]