9.Write a Pandas program to append a list of dictionaries or series to an existing DataFrame and display the combined data.
9.Write a Pandas program to append a list of dictionaries or series to an existing DataFrame and display the combined data.
Solution :-
import pandas as pd
import numpy as np
data_info = {'name':['abc','xyz','pqr','asd','mno'],
'perc':[78,76,98,89,72],
'qualify':['yes','yes','yes','yes','yes']}
df = pd.DataFrame(data_info)
s1 = pd.Series(['bkh','89','yes'],index = ['name','perc','qualify'])
dicts = {'name':'abc1','perc':'89','qualify':'yes'}
print("---------------Original DataFrame -------")
print(df)
print("----------------------Append the DataFrame -------------------- ")
series = df.append(s1,ignore_index=True,sort=False)
dic12 = series.append(dicts,ignore_index=True,sort=False)
print("------------------------- Combined DATA ---------------------")
print(dic12)
Output :-