I was working with twitter data, and extracted every emoji from the data. But, when I passed that data through
CountVectorizer, colons where substracted from the strings. So, the string emoji
:ok_hand: :thumbs_up: turned into
ok_hand thumbs_up. I wanted to re-add those colons so then I could emojize them back. I managed to do that, but I'm quite sure my method is very inefficient. The emojis are the indexes of a coefficients DataFrame, like this:
index coef ok_hand thumbs_up 0.4 airplane 0.2
So what I did was this:
to_emojize=pd.Series(coef_mat_emoji.index) to_emojize=to_emojize.apply(lambda x: x.split()) to_emojize=to_emojize.apply(lambda x:[':'+i+':' for i in x]) to_emojize=to_emojize.apply(lambda x: emoji.emojize(x, use_aliases=True)) coef_mat_emoji.index=to_emojize
Is there a better way to do this?