slzdevsnp
9/26/2019 - 3:50 PM

[pandas merge] #pandas #merge

[pandas merge] #pandas #merge

import pandas as pd
import numpy afs np


df1 = pd.DataFrame({'lkey': ['foo', 'bar', 'baz', 'foo'],
                    'value': [1, 2, 3, 5]
                   })

df2 = pd.DataFrame({'rkey': ['foo', 'bar', 'baz', 'foo'],
                    'value': [5, 6, 7, 8]
                   })

####################
#   merge asof
####################
#left_on, right_on can be lists of equal size
df1.merge(df2, left_on='lkey', right_on='rkey', how='inner' )