Pandas Series.tolist错误地记录了空白空间?

时间:2019-01-02 22:54:27

标签: python pandas

我有一个名为df的Pandas DataFrame,其中有一个名为eligible?的列,其中可以包含"Yes""No"

因此,我想从eligible?列包含“是”的行中选择所有名称。所以我这样做:

df[df["eligible?"].str.lower().str.startswith("y")]["name"]

我查看了Series的输出,结果与预期的一样。名称之一是"John "(注意尾随空格)。

当我这样做时:

df[df["eligible?"].str.lower().str.startswith("y")]["name"].tolist()

我返回了一个列表,但是现在具有"John "的行具有"John\xe3\x80\x80"

知道这里发生了什么吗?

如果有帮助,我将从utf-8编码的CSV中读取DataFrame。

谢谢!

0 个答案:

没有答案
相关问题