我想将pandas dataframe保存为Stata文件,但似乎存在一个问题,即列具有int64
或{int
和{
我试过使用类似的方法:
import numpy as np
def conversion(obj):
if isinstance(obj, np.generic):
return np.asscalar(obj)
mergeddfnew["speech_main_wordspersentcount_wc"]=mergeddfnew["speech_main_wordspersentcount_wc"].apply(conversion)
我也试过打字。列的类型始终保持不变。在
参见IO section of the docs:
不过,熊猫会尽力克服这些限制,为你转化:
也就是说,你的专栏似乎不满足这些条件。在
我会尝试手动将其转换为dta支持的int32(假设它是int):
相关问题 更多 >
编程相关推荐