Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use pandas.concat instead. FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

Use list, for dictionary dont use dict name, because code name 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  
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading