I have a dataframe ('DF1') and I have a dict ('dictdf'). I want to add columns headers based on the dict, those columns needs to be empty.
DF1:
ID age
12 33
23 55
67 12
result:
ID age height eye_color ....
12 33 NA NA ....
23 55 NA NA ....
67 12 NA NA ....
This is what I tried:
colNames = DF1.columns
for key in dictdf.keys():
colNames.append(key)
newDF = pd.DataFrame(DF1,columns=colNames)
Error:
TypeError: all inputs must be Index
Any idea on a simple solution? I don't want to start transforming from dict to DF or the other way around.