Write a Pandas program to filter words from a given series that contain atleast two vowels
- برمجة بايثون
- 2021-09-10
- mhanasmh00489829403
الأجوبة
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
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال