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:
TypeError: unhashable type: 'DataFrame'
What am I doing wrong ?
CodePudding user response:
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']})])