python 2.7 - Trouble with pandas merge function -
i trying merge 2 panda's data frame using merge
function. here top few lines of both data frames.
newdf 0 1x 0 1 farm products 1 11 field crops 2 112 cotton, raw 3 1129 raw cotton, nec 4 1131 barley
and
df_2012 0 1 2 3 4 0 1 657042 52539820 103009 10818958 1 11 613499 51051986 99650 10525341 2 112 10710 233790 0 0 3 1121 0 0 0 0 4 1131 13276 998109 3560 0
when merge following command:
pd.merge(newdf, df_2012, on = [newdf.columns[0]], how = 'right')
i getting following:
0 1x 1 2 3 4 0 1 nan 657042 52539820 103009 1 11 nan 613499 51051986 99650 2 112 nan 10710 233790 0 0 3 1121 nan 0 0 0 0 0 4 1131 nan 13276 998109 3560
i don't understand why new merged data frame's '1x'
column has nan
s. thought keys doesn't appear on left data frame, in newdf
, appear nan
s. rows keys matches in both data frames show other column values both data frames.
what missing here ?
thanks input make me understand problem.
Comments
Post a Comment