0

I have two lists that I want to find their intersection.

b = set(a)& set(list_a)
b
{'118184', '907', '95828', '95957', '95977', '95983', '95984', '95985'}

Now I want b to be a list (instead of set) so I tries

b.apply(list)

(How can I convert set to list in pandas?)

And I'm getting the following error:

 ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-273-cfd36ffc3bfc> in <module>()
----> 1 b.apply(list)

AttributeError: 'set' object has no attribute 'apply'

Thanks!

Adi Milrad
  • 135
  • 3
  • 9

1 Answers1

2

b=list(b) does seem to work (@jezrael comment)

>>> a=[1,2,3]
>>> c=[2,3,4]
>>> b=set(a) & set(c)
>>> b
{2, 3}
<class 'set'>
>>> b=list(b)
>>> b
[2, 3]
Sruthi
  • 2,908
  • 1
  • 11
  • 25