in some casesthe merge key or keys in dataframe will be found in its index in this caseyou can pass left_index=true or right_index=true (or bothto indicate that the index should be used as the merge keyin [ ]left dataframe({'key'[' '' '' '' '' '' ']'value'range( )}in [ ]right dataframe({'group_val'[ ]}index=[' '' ']in [ ]left out[ ]key value in [ ]right out[ ]group_val in [ ]pd merge(left right left_on='key'right_index=trueout[ ]key value group_val since the default merge method is to intersect the join keysyou can instead form the union of them with an outer joinin [ ]pd merge(left right left_on='key'right_index=truehow='outer'out[ ]key value group_val nan with hierarchically-indexed datathings are bit more complicatedin [ ]lefth dataframe({'key '['ohio''ohio''ohio''nevada''nevada']'key '[ ]'data'np arange( )}in [ ]righth dataframe(np arange( reshape(( ))index=[['nevada''nevada''ohio''ohio''ohio''ohio'][ ]]columns=['event ''event ']in [ ]lefth out[ ]in [ ]righth out[ ] data wranglingcleantransformmergereshape www it-ebooks info