append dataframe to another dataframe

37

append dataframe to another dataframe -

>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'), index=['x', 'y'])
>>> df
   A  B
x  1  2
y  3  4
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'), index=['x', 'y'])
>>> df.append(df2, ignore_index=True)
   A  B
x  1  2
y  3  4
x  5  6
y  7  8

how to append a dataframe to another dataframe in pandas -

# all_res is list of DataFrames : [ dataframe, dataframe, ... ]
df_res = pd.concat(all_res)

Comments

Submit
0 Comments