Python Forum

Full Version: Pandas Extract data from two dataframe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi have help You, I need to extract data based on a column of a dataframe on another practice with df1.codbar I have to filter all the data in df2 taking into account that df2.sku in df1 is called df1.codbar

df1 = pd.DataFrame({'codbar':['K0', 'K4', 'K2']})

df2 = pd.DataFrame({'stock_status': ['C0', 'C2', 'C3'],
'stock_quantity': ['D0', 'D2', 'D3'],
'sku':['K0', 'K2', 'K3']})

resultThatScholdBe = df2{'stock_status': ['C0'],
'stock_quantity': ['D0'],
I think I have found, I did like this:

df2 = df2[df2.sku.isin(df1.codbar)]