Pandas
Pandas (24)
알 수 없는 사용자
2022. 8. 15. 22:34
728x90
How to filter words that contain atleast 2 vowels from a series?
# Input
ser = pd.Series(['Apple', 'Orange', 'Plan', 'Python', 'Money'])
# Solution
from collections import Counter
mask = ser.map(lambda x: sum([Counter(x.lower()).get(i, 0) for i in list('aeiou')]) >= 2)
ser[mask]
# output
0 Apple
1 Orange
4 Money
dtype: object