![]() |
Pandas Extract data from two dataframe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Pandas Extract data from two dataframe (/thread-31665.html) |
Pandas Extract data from two dataframe - nio74maz - Dec-26-2020 Hi have help You, I need to extract data based on a column of a dataframe on another dataframe.in 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'], 'sku':['K0']} RE: Pandas Extract data from two dataframe - nio74maz - Dec-26-2020 I think I have found, I did like this: df2 = df2[df2.sku.isin(df1.codbar)] |