Filter words from a given Pandas series that contain atleast two vowels
In this article, how we can filter the words from a given series which contain two or more vowels. Here we’ll see two ways in which we can achieve this.
In this example we’ll use the map() function to loop through the series and check for each word if the count of vowels is greater than or equal to two. map is basically used to loop through the series and Counter is used to count the number of vowels in each word.
In this example we’ll use the Series.str.count() function with regex to loop through the series and check for each word if the count of vowels is greater than or equal to two. (?i) is used to start case-insensitive mode, to convert the uppercase character to lowercase characters. We need to convert uppercase characters to lowercase because for vowels we are comparing with lowercase vowels, so whenever an uppercase vowels appears like in Apple we need to convert ‘A’ to lowercase for proper comparison.
Please Login to comment...