I have a dictionary that has the following structure:
'username1': { 'attributes': { 'AccountType': ['01'],
'UnitCode': ['001'],
'UnitDesc': ['Marketing'],
'title': ['Assistant'], },
'extra': 'CN=000000' }
'username2': { 'attributes': { 'AccountType': ['01'],
'UnitCode': ['002'],
'UnitDesc': ['Resources'],
'title': ['Manager'], },
'extra': 'CN=000000' }
I am trying to achieve this output in a DataFrame:
+-----------+-------------+----------+
| | AccountType | UnitCode |
+-----------+-------------+----------+
| username1 | 01 | 001 |
| username2 | 01 | 002 |
+-----------+-------------+----------+
The answer provided on a similar question here got me closer to what I was after, but I need to drop the data in the 'extra' section.
df = pd.concat({k: pd.DataFrame(v).T for k, v in mydict.items()}, axis=0)
When I call df.index it looks like this:
MultiIndex([('username1', 'attributes'),
('username1', 'extra'),
('username2', 'attributes'),
('username2', 'extra')])
I've attempted to remove the content from the dataframe after conversion and also from the dictionary before converting to no success. I'm not sure how to stop the duplication.