如何检查 Pandas 数据帧中的希腊字符

问题描述 投票:0回答:1

我有一个从 XLSX 电子表格创建的数据框,其中单元格中有 Ω。 (此处显示的字符是通过输入 Alt-234 生成的)

df.unit.iloc[1]
返回“Ω”

但是

df.unit.iloc[1] == 'Ω'
'Ω' in df.unit.iloc[1]
都返回 False

我尝试使用 '\u03A9' 得到相同的结果。我错过了什么?

(Python 3.11)

python pandas unicode
1个回答
0
投票

不知何故,你的代码在我的情况下有效。

import pandas as pd
df = pd.DataFrame({"unit":["A", 'Ω']})
df.unit.iloc[1] == 'Ω'

您能提供 DataFrame 示例吗?

© www.soinside.com 2019 - 2024. All rights reserved.