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
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)]

Possibly Related Threads…
Thread Author Replies Views Last Post
  Structuring and pivoting corrupted dataframe in pandas gunner1905 2 134 Sep-18-2021, 01:30 PM
Last Post: gunner1905
  Build a matrix by pressing buttons of an interface in Tkinter which extract data from juandiegopulla 1 139 Sep-13-2021, 07:28 PM
Last Post: deanhystad
  TypeError: 'DataFrame' object is not callable using Pandas in Python sofiavlachou 1 156 Sep-02-2021, 03:24 PM
Last Post: buran
  Problem in saving .xlsm (excel) file using pandas dataframe in python shantanu97 2 234 Aug-29-2021, 12:39 PM
Last Post: snippsat
  Python Pandas: How do I average ONLY the data >1000 from several columns? JaneTan 0 314 Jul-17-2021, 01:34 PM
Last Post: JaneTan
  Python Pandas: How do I extract all the >1000 data from a certain column? JaneTan 0 290 Jul-17-2021, 09:09 AM
Last Post: JaneTan
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 331 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas dictionary dataframe help michaelserra 4 469 Jun-19-2021, 10:26 AM
Last Post: michaelserra
  Reading data to python: turn into list or dataframe hhchenfx 2 542 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 474 May-04-2021, 10:51 PM
Last Post: rhat398

Forum Jump:

User Panel Messages

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