Converting a Dataframe Column of Dictionaries into New Columns based on Keys
Turns out that the above methods posted didn't work while the strings in question were in unicode.
This finally worked:
df['students'] = df['students'].map(eval)
df2 = pd.concat([df.drop('students', axis=1), pd.DataFrame(df['students'].tolist())], axis=1)
I appreciate the answers posted, thanks a bunch everyone.
I have a Pandas dataframe column that consists of several dictionaries in the format of:
df[students] = {u'51': [u'1592', u'1582', u'1272', u'459', u'1254', u'1267'], u'32': [u'1659', u'1322', u'1396', u'1315', u'1342', u'1661']} {u'51': [u'1592', u'1582', u'1272', u'459', u'1254', u'1267'], u'32': [u'1659', u'1322', u'1396', u'1315', u'1342', u'1661']}
... and so on for several more entries.
Each dictionary represents one entry in the dataframe. I would like to convert this column into 2 new columns where the keys (51 and 32) are the column headers, and the values go into each column accordingly. I used the df.to_list() and Pd.Series() methods which seemed to work at first, but when I replicated it, it didnt change the data at all. Is there something I'm missing here?