鉴于dict值的pandas Seriesstr键:

Series
------
{'a': 1, 'b' : 2, 'c' : 3}
{'b': 3, 'd': 5}
{'d': 7, 'e': 7}

如何能在系列扫描检索一组的字典键的?所产生的输出将是一个普通的python组:

{'a', 'b', 'c', 'd', 'e'}

预先感谢您的关怀和response。

分析解答

使用list理解与扁平化,并转换为集:

a = set([y for x in s for y in x])
print (a)
{'e', 'a', 'd', 'c', 'b'}

或者使用itertools.chain.from_iterable

from  itertools import chain

a = set(chain.from_iterable(s))