I have two pandas dataframe that I am trying to join. The key in df1
is a substring of key in df2
. Here's sample data for Illustration.
import pandas as pd
df1 = pd.DataFrame({
'id': [22380, 10380, 22380],
'n': ['A', 'B', 'C']
})
df2 = pd.DataFrame({
'id': ['SMS04223800000000001', 'SMS04103800000000001', 'SMS04223800000000001'],
'v': [10, 12, 15]
})
})
Expected output after merging:
id n v
SMS04223800000000001 A 10
SMS04103800000000001 B 12
SMS04223800000000001 C 15