Write a Pandas program to filter words from a given series that contain atleast two vowels.
import pandas as pd from collections import Counter color_series = pd.Series(['Red', 'Green', 'Orange', 'Pink', 'Yellow', 'White']) print("Original Series:") print(color_series) print("\nFiltered words:") result = mask = color_series.map(lambda c: sum([Counter(c.lower()).get(i, 0) for i in list('aeiou')]) >= 2) print(color_series[result])
Sample Output:
Original Series: 0 Red 1 Green 2 Orange 3 Pink 4 Yellow 5 White dtype: object Filtered words: 1 Green 2 Orange 4 Yellow 5 White dtype: object
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer