Home > database >  Append row to an empty data frame
Append row to an empty data frame

Time:11-11

Can someone please explain me how I add a row to an empty data frame?

df1 = pd.DataFrame([], columns = ['abc', 'def'])
df2 = pd.DataFrame([[5, 10]], columns = ['abc', 'def'] )

df1.append(df2)
df1

Just trying to understand the example in the documentation.

df1 is still empty.

CodePudding user response:

you have to updade df1 , like this

df1 = df1.append(df2)
  • Related