The example would be a list called 'main' looks like
main = [('date', '2020-04-21'), ('oldname', 'Tap'), ('newname', 'Tapnew'), ('icon_url', '3'), ('date', '2020-04-21'), ('oldname', 'Nod'), ('newname', 'Nodnew'), ('icon_url','4'), ('date', '2020-04-21'), ('oldname', 'Mik'), ('newname', 'Miknew'), ('icon_url','5')]
I've tried to directly parse and transform using this.
df = pd.DataFrame(main)
test = df.T
test.columns = test.iloc[0]
a = test.drop(test.index[0])
However the result dataframe is still a long sparse form with repeated columns
date oldname newname icon_url date oldname newname icon_url date oldname newname icon_url
2020-04-21 Tap Tapnew 3 2020-04-21 Nod Nodnew 4 2020-04-21 Mik Miknew 5
The desired output would be
date oldname newname icon_url
2020-04-21 Tap Tapnew 3
2020-04-21 Nod Nodnew 4
2020-04-21 Mik Miknew 5
I've been struggle the whole day --- Can anyone shed some lights on this? Thanks in advance.