I have a dictionary and an empty dataframe. I was trying to append the dictionary to the pandas dataframe but I got this warning.
I tried this:
dict = {
'city_name': 'Ixelles',
'type_of_property': 0,
'price': 0,
'number_of_rooms':2,
'house_area':120,
'fully_equipped_kitchen':1,
'open_fire':0,
'terrace':1,
'garden':0,
'surface_of_the_land':120,
'number_of_facades':1,
'swimming_pool':0,
'as new':0,
'good':0,
'just renovated':1,
'to be done up':0,
'to renovate':0,
'to restore':0,
'unknown':0
}
df_predict = df_predict.append(dict, ignore_index = True)
But I got this warning: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
I also tried this:
df_predict = pd.DataFrame.from_dict(dict)
but I got this error then:
If using all scalar values, you must pass an index
What am I missing?
CodePudding user response:
Use list, for dictionary dont use dict
name, because code word in python:
df_predict = pd.DataFrame([di])
print (df_predict)
city_name type_of_property price number_of_rooms house_area \
0 Ixelles 0 0 2 120
fully_equipped_kitchen open_fire terrace garden surface_of_the_land \
0 1 0 1 0 120
number_of_facades swimming_pool as new good just renovated \
0 1 0 0 0 1
to be done up to renovate to restore unknown
0 0 0 0 0