Data merging in python(Data Minig)



Hey All,
Can anyone help me to know why data value(No. of rows) is less after merging, and how i can get the all data of GEN_3 with merge one column from P_List.
Note: In both the file one "Key"column is there.

GEN_3=  pd.read_csv("~/Dec.csv",encoding="iso-8859-1")
P_List = pd.read_csv("~/P_List.csv",encoding="iso-8859-1")
GEN_Mer = pd.merge(GEN_3,P_List)

(442155, 8)
(377761, 9)

Thank You


You need to specify the how do you want to merge the two dataframes. Default value of how is ‘inner’ so only, the same values will be merged. I think what you want is append. Append the both the dataframes and then you can get your desired result.


Apply left merge on key column.It will work.

Df = GEN_3.merge(P_List,how=“left”,on=“keycolumn”)

Link for reference: