0
您能否支持我阐明将选定的Dataframe列转换为字符串的正确方法?python3熊猫 - #TypeError:不能将'int'对象隐式转换为str
如果我用下面的语句数据框 'DF' 的 'PRODUCT_ID' 部分被自动选择为整数
:
df['Product_ID']=df['Product_ID'].to_string()
产生错误:
TypeError: Can't convert 'int' object to str implicitly
由产生同样的问题.astype(str)
或.apply(str)
临时NKS!
感谢您的及时答复。 – gualfab
感谢您的及时回复。我使用了命令:TypeCheck = df.dtypes并验证'Product_ID'是'int64'...我尝试添加一个新列df ['Project_ID_textcopy'] = df ['Project_ID'] .to_string()正常。这似乎是问题产生时,我要求在同一行重写列本身df ['Project_ID'] = df ['Project_ID']。to_string() – gualfab
有趣的是,我仍然无法重现这一点。 – exp1orer