I have a DataFrame
with following columns:
columns = ['Autor', 'Preţul', 'Suprafaţa totală', 'Etaj', 'Etaje', 'Tipul casei', 'Tipul de camere','Numărul de camere','Starea apartamentului', 'Planificare', 'Tipul clădirii', 'Sectorul', 'Strada', 'Numărul casei']
df = pd.DataFrame(columns=columns)
I want to add to this DataFrame
a number of dictionaries row by row, for instance for the first row I want to ad this dictionary:
{'Autor': nan,
'Balcon/lojă': '2',
'Etaj': '1',
'Grup sanitar': 'separat',
'Locul de amplasare în casă': 'In mijlocul casei',
'Numărul casei': nan,
'Numărul de camere': '4 şi mai multe camere',
'Parcare': 'deschisă',
'Preţul': nan,
'Sectorul': nan,
'Strada': nan,
'Suprafaţa totală': '90 m²',
'Tipul clădirii': 'Dat în exploatare'}
The values of the keys of the dictionary that are not in the DataFrame
columns should be set as NaN
values. The dictionaries had only a part of the columns names as keys.
for instance the second dict:
{'Autor': nan,
'Numărul casei': nan,
'Numărul de camere': '3 camere',
'Preţul': nan,
'Sectorul': nan,
'Strada': nan,
'Suprafaţa totală': '103 m²',
'Tipul clădirii': 'Dat în exploatare'}
The dictionaries are results of a for loop and they should be added as unique row.