-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
  • 26,923
  • 21
  • 73
  • 125

1 Answers1

0
Match = df.loc[df['ID'].isin(L),'Num']
BICube
  • 4,011
  • 1
  • 20
  • 40