I have the following table:
CODE VALUE FIELD INDEX
AR002 012014 001 001
AR002 2343244,29 002 001
AR002 1214124,19 007 001
AR002 1001 011 001
AR002 16022024 014 001
I need to obtain the following output:
001 002 007 011 014
012014 2343244,29 1214124,19 1001 16022024
So, for each CODE and INDEX, I need to create the columns based on FIELD. I try with the method pivot() from Pandas, but it gives me the following output:
df.pivot(columns='FIELD', values='VALUE')
001 002 003 004 007 008 009 010 011 013 014
012021 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 NaN 2343244,29 NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 NaN NaN NaN NaN 1214124,19 NaN NaN NaN NaN NaN NaN
3 NaN NaN NaN NaN NaN NaN NaN NaN 1001 NaN NaN
4 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 16022024