0

I am trying to make a data frame from a smaller data frame using this code:

seed_request = [(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')]
print(seed_request)

This is giving me a new data frame with either True or False depending on if these conditions are met. How do I make it instead give me a data frame with the rows that satisfy these conditions?

  • `inventory.loc[(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')]` – bigbounty Jul 13 '20 at 20:59
  • You may think about accepting an answer to reward those how helped you, or at least comment to explain what's missing ;) – azro Jul 19 '20 at 12:50

2 Answers2

2

seed_request = [(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')] print(inventory.iloc[seed_request])

Ricardo
  • 350
  • 1
  • 10
1

You need to apply the filter on the dataframe

seed_request = inventory[(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')]
azro
  • 53,056
  • 7
  • 34
  • 70