Pandas中的Unicode,python2.7

2024-10-01 00:22:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我读了很多关于这方面的文章,但我仍然不能确定并找到一个对所有人都有用的答案,特别是关于Python2.7中熊猫行为的问题。在

在Pandas、python2.7中用str或Unicode“重铸”更好吗? (选项1或选项2)

选项1:

 df = pd.DataFrame({'b':['ホテ','・旅館', 'ホテル']})
 df= df.astype({ 'b': 'unicode'})

选项2:

^{pr2}$

根据引用,在进行任何处理之前,所有内容都应该以Unicode格式输入?在

参考文献: Python str vs unicode types


Tags: 答案内容dataframepandasdf选项文章unicode