【问题标题】:Converting from Unicode in Python在 Python 中从 Unicode 转换
【发布时间】:2013-05-05 19:14:54
【问题描述】:

如何将 Unicode 转换为字符串?

df = pd.DataFrame ({'A':[u'Joe', u'Bill']})
test = df['A'] == 'Joe'

这适用于将完整的列转换为 Unicode 到浮点数:

df['B'] = df['B'].astype(float)

但是当我尝试时:

df['A'] = df['A'].astype(str)

输出是:

0    J
1    B

【问题讨论】:

  • Unicode 字符串是字符串。他们会给你带来麻烦吗?

标签: python unicode pandas


【解决方案1】:

Unicode 是字符串,不需要转换。

【讨论】:

    猜你喜欢
    • 2018-08-16
    • 1970-01-01
    • 2014-04-03
    • 2012-05-03
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多