Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [600]: A = df.query('letter == "A"').code.item()
- In [601]: df.code.apply(lambda x: len(set(x).intersection(A))/float(len(A)))
- Out[601]:
- 0 1.000000
- 1 0.333333
- 2 0.333333
- Name: code, dtype: float64
- In [602]: B = df.query('letter == "B"').code.item()
- In [603]: df.code.apply(lambda x: len(set(x).intersection(B))/float(len(B)))
- Out[603]:
- 0 0.5
- 1 1.0
- 2 1.0
- Name: code, dtype: float64
- In [604]: A
- Out[604]: ['13.45', '16.59', '12.28']
- In [605]: B
- Out[605]: ['13.45', '18.20']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement