All Courses

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

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

Why You Should Learn Data Science in 2023?

Jun 8th (7:00 PM) 289 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More