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

By Albert, 2 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

Join AI Webinar With Top AI Experts on 20th June 2021 at 06 PM

Jun 20th (6:00 PM) 691 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More