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

How to use concat instead of append, without having any Future Warning

I am using append

DF= pd.DataFrame(columns=['Col1', 'Col2', 'Col3'])
DF = DF.append({'Col1': "A",  'Col2'  : 'B'  ,'Col3':  'C'},ignore_index=True)

Which was working fine, Now I try to use concat instead :

DF= pd.DataFrame(columns=['Col1', 'Col2', 'Col3'])
DF = pd.concat([DF],pd.DataFrame({'Col1': ['A'],'Col2':['B'],'Col3':['C']}))

But this does throw the following error:

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

TypeError: unhashable type: 'DataFrame'

What am I doing wrong ?

>Solution :

pd.concat takes a list of dataframes to concatenate as the first argument. You should put both the dataframes in the list:

DF= pd.DataFrame(columns=['Col1', 'Col2', 'Col3'])
DF = pd.concat([DF, pd.DataFrame({'Col1': ['A'],'Col2':['B'],'Col3':['C']})])
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