Tuesday, 26 April 2022

Append Tables' Rows

 How to add rows from another table to existing dataframe? 

import pandas as pd

df1 = pd.DataFrame({"x": [5, 2], "y": [4, 7], "z": [9, 3]})
df2 = pd.DataFrame({"x": [1, 3], "y": [1, 9], "z": [29, 30]})

print "Input DataFrame 1 is:\n", df1
print "Input DataFrame 2 is:\n", df2

df3 = df1.append(df2, ignore_index=True)

print "After appending, DataFrame is: \n", df3

 

No comments:

Post a Comment