I have a dataframe that has one of the columns as a dictionary. I want to unpack it into multiple columns (i.e. code, amount are separate columns in the below Raw column format). The following code used to work with pandas v0.22, now (0.23) giving an index error:
pd.DataFrame.from_records(df.col_name.fillna(pd.Series([{'code':'not applicable'}], index=df.index)).values.tolist())
ValueError: Length of passed values is 1, index implies x
I searched google/stack overflow for hours and none of the other solutions previously presented work anymore.
Raw column format:
dict_codes
0 {'code': 'xx', 'amount': '10.00',...
1 {'code': 'yy', 'amount': '20.00'...
2 {'code': 'bb', 'amount': '30.00'...
3 {'code': 'aa', 'amount': '40.00'...
10 {'code': 'zz', 'amount': '50.00'...
11 NaN
12 NaN
13 NaN
Does anyone have any suggestions?
Thanks