-1

I have a list, "L" and a DataFrame, "df" and I wish to extract a certain column value only where the L and a certain df column match.

L = [299]
Match = []

df:
['ID']    ['Num']
299       1
300       3
....      ....

I wish to see 1 when I print Match:

print(Match):

1
Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0
Match = df.loc[df['ID'].isin(L),'Num']
BICube
  • 4,451
  • 1
  • 23
  • 44