0

I am trying to use an output within another line of code as a list. I want to find the product code where the ordernumber equals the following values:

ordnumber = [10334, 10401, 10407, 10414]

The input:

(orderdetails_df.productcode).where(orderdetails_df.ordernumber == ordnumber)

I get back the error:

ValueError: Lengths must match to compare
ALollz
  • 57,915
  • 7
  • 66
  • 89
  • 1
    Use `.isin`: `orderdetails_df.ordernumber.isin(ordnumber)`: https://stackoverflow.com/questions/19960077/how-to-implement-in-and-not-in-for-pandas-dataframe – ALollz Aug 13 '19 at 15:44

1 Answers1

0

I would do it this way:

orderdetails_df.loc[orderdetails_df.ordernumber.isin(ordnumber), productcode]
ivallesp
  • 2,018
  • 1
  • 14
  • 21