Pandas 系列独特的方法显示看起来相同的值

Pandas Series unique method showing values looking the same

我有一个 pandas 数据框。当我 运行 将 .unique() 方法应用于其中一列时,它显示看起来相同的值。我怎样才能看到这些值有何不同?我尝试从 unique() 方法进行索引,但值只是字符串,如下所示。感谢您的帮助。

df["MyColumn"].unique()
array(['yi̇', 'yd', 'yi'], dtype=object)
_______________________________________
df["MyColumn"].unique()[0]
'yi̇'
_______________________________________
df["MyColumn"].unique()[2]
'yi̇'

仔细观察你会发现不同之处:

'yi̇' # the i letter has two dots
'yi' # normal i letter

所以你似乎看到了两个不同的 unicode 字符,但是它们看起来非常相似。

你可以检查 ascii 码有什么区别,这里先 i 是特殊值 775 就像评论中提到的 Er Bharath Ram:

u = ['yi̇', 'yd', 'yi']
print ([list(map(ord,i)) for i in u])
[[121, 105, 775], [121, 100], [121, 105]]