0

I'm sorry if i'm doing something wrong but that is my first question. I have a list of emoji in pandas dataframe, but when i use it, i just have back the string instead of the image.

print(emoji['emoji'].iloc[j])
Output: \U0001F600

Instead, if i manually write it and put it into a string,it works.

stinga = '\U0001F600'
Output: 

I also checked the type of both and it give me str, so i dont really know what to do. Thank you for help

francesco
  • 43
  • 1
  • 6

2 Answers2

1

Works for me in the standard Python REPL:

>>> import pandas as pd
>>> d = {'emoji': ['', '', '', '', '']}
>>> d
{'emoji': ['', '', '', '', '']}
>>> df = pd.DataFrame(data=d)
>>> df
  emoji
0     
1     
2     
3     
4     
>>> for i in range(len(df['emoji'])):
...     print(df['emoji'].iloc[i])
...





>>>

Screenshot of output in case browser doesn't load emojis:

Emoji pandas screenshot

You could also try running your pandas code in something like Google Colab in a modern browser that has emoji support turned on (e.g., some Linux distros need you install emojis explicitly, or the default browser installations on them need you to turn them on):

Google Colab Emoji

Sash Sinha
  • 18,743
  • 3
  • 23
  • 40
  • if i write you code,it works, but if in my program i check '\U0001F600' == emoji['emoji'].iloc[j] it return false – francesco Oct 31 '20 at 14:02
0

I also get the same problem as you. This solution is works for me, Best and clean way to Encode Emojis (Python) from text file

show = (emoji['emoji'].iloc[j].encode("latin_1")
  .decode("raw_unicode_escape")
  .encode('utf-16', 'surrogatepass')
  .decode('utf-16')
) 


print(show)
# 

This problem might be caused by the data in dataframe is read as plain text, so you need to change the format first so it can show the emoji, if utf-16 doesn't work try to change to utf-8