I have a dataframe with a column "clear_message", and I created a column that counts all the words in each row.
history['word_count'] = history.clear_message.apply(lambda x: Counter(x.split(' ')))
For example, if the rows message is: Hello my name is Hello
Then the counter in his row, will be Counter({'Hello': 2, 'is': 1, 'my': 1, 'name': 1})
The problem
I have emoji in my text, and I want also a counter for the emoji.
For example:
test = '
I think your idea of adding a space after each emoji is a good approach. You'll also need to strip white space in case there already was a space between an emoji and the next character, but that's simple enough. Something like:
Maybe you could improve this by using a sliding window to check for spaces after emojis and only add spaces where necessary, but that would assume there will only ever be one space, where as this solution should account for 0 to n spaces between emojis.
there was some problems with @con-- answer, so I fixed it.
example: