Find a words that contain at least 3 vowels from a series?

By Albert, 7 months ago
  • Bookmark
0

From given series , extract words that contain at least 3 vowels.

Series
1 Answer
1

# Input
ser = pd.Series(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday','Friday','Satrday'])

# Solution
from collections import Counter
mask = ser.map(lambda x: sum([Counter(x.lower()).get(i, 0) for i in list('aeiou')]) >= 3)
ser[mask]

Output

2      Tuesday
3    Wednesday
dtype: object


Your Answer

Webinars

Live Masterclass on : "How Machine Learns in Machine Learning"

Dec 9th (6:00 PM) 222 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More