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
  Python Pandas: How do I average ONLY the data >1000 from several columns? JaneTan 0 201 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 196 Jul-17-2021, 09:09 AM
Last Post: JaneTan
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 203 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas dictionary dataframe help michaelserra 4 321 Jun-19-2021, 10:26 AM
Last Post: michaelserra
  Reading data to python: turn into list or dataframe hhchenfx 2 332 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 344 May-04-2021, 10:51 PM
Last Post: rhat398
  Need help on extract dynamic table data Dr_Strange 0 592 Apr-30-2021, 07:03 AM
Last Post: Dr_Strange
Star Split and organize my Pandas Dataframe brunolelli 4 602 Apr-18-2021, 03:00 AM
Last Post: brunolelli
  How to save json data in a dataframe shantanu97 1 446 Apr-15-2021, 02:44 PM
Last Post: klllmmm
  Convert MultiLayer XML to DataFrame using Pandas vsingh17 0 498 Apr-14-2021, 03:50 PM
Last Post: vsingh17

Forum Jump:

User Panel Messages

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