How to bind rows into a data frame using python?

Description

To concatenate new rows with a data
frame in python.

  Get the sample data.

  Make two different data frame.

  Binding the needed row from one
to another data frame.

  Its used to take the row,what we want.

#import library
import matplotlib.pyplot as plt
import pandas as pd

#10 sample data
data={‘name':[‘sathish’,’raj’,’raja’,’krishna’,’yusuf’],
‘salary':[100,200,300,400,500],
‘age':[25,26,25,23,30],
‘rating':[4,3.24,2.5,2.25,2]}
data1={‘name':[‘praveen’,’sangee’,’ezhil’,’dinesh’,
‘ganesh’],
‘salary':[400,300,200,100,50],
‘age':[29,23,23,24,25],
‘rating':[2.25,2.5,2.75,3.2,4.2],
‘bonus':[1400,850,250,750,1000]}
df=pd.DataFrame(data)
df1=pd.DataFrame(data1)

print(“First Data frame”)
print(df)
print(“Second Data frame”)
print(df1)

#Concatenate the row from data frame df1
df.append(df1,sort=False)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit