python与R兼容羽毛与字符串
我在将一个羽毛对象读入从
python会话中输出的R时遇到错误.
在python中: In [248]: import pandas as pd In [249]: pd.DataFrame({'col': ['a','b','c']}).to_feather('strings_df.feather') 在R: > library(feather) > df = read_feather('strings_df.feather') Error in coldataFeather(x,i) : RAW() can only be applied to a 'raw',not a 'list' 这与字符串在pandas.Series中存储为对象的事实有关吗?关于这里发生了什么的任何想法? 会话信息: [R
Python
解决方法
问题很简单,字符串列中的值应该是unicode类型,而不是str.以下按预期工作:
pd.DataFrame({'col': [u'a',u'b',u'c']}).to_feather('strings_df.feather') (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |