Python Forum
Pandas Extract data from two dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Extract data from two dataframe
#1
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']}
Reply
#2
I think I have found, I did like this:

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why can't it extract the data from .txt well? Melcu54 4 1,749 Dec-12-2024, 07:36 PM
Last Post: Melcu54
  Most efficient way to roll through a pandas dataframe? sawtooth500 2 1,067 Aug-28-2024, 10:08 AM
Last Post: Alice12
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 1,023 Aug-26-2024, 10:14 PM
Last Post: shwfgd
  Confused by the different ways of extracting data in DataFrame leea2024 1 643 Aug-17-2024, 01:34 PM
Last Post: deanhystad
  Python script to extract data from API to database melpys 0 821 Aug-12-2024, 05:53 PM
Last Post: melpys
  docx file to pandas dataframe/excel iitip92 1 2,389 Jun-27-2024, 05:28 AM
Last Post: Pedroski55
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 3,501 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 1,336 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  Filter data into new dataframe as main dataframe is being populated cubangt 8 2,980 Oct-23-2023, 12:43 AM
Last Post: cubangt
  Better python library to create ER Diagram by using pandas data frames as tables klllmmm 0 3,021 Oct-19-2023, 01:01 PM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020