It is intrducing nulls in resultant dataframe df.pivot( columns='colname',values='value')
Initial DF:
colname value
0 bathrooms 1.0
1 bathrooms 2.0
2 bathrooms 1.0
3 bathrooms 2.0
4 property_id 82671.0
enter image description here
Result:
colname addr_street bathrooms bedrooms lat lng parking_space property_id
0 NaN 1.0 NaN NaN NaN NaN NaN
1 NaN 2.0 NaN NaN NaN NaN NaN
2 NaN 1.0 NaN NaN NaN NaN NaN
I just want a dataframe where unique values of 'colname' in initial df are the columns and the its corresponding value is the value(like it happens in bathroom)