【发布时间】:2021-07-19 20:28:38
【问题描述】:
我在以下代码中收到SettingWithCopyWarning:
combined_updated['institute_service'] = combined_updated['institute_service'].copy().astype('float')
社区中的人可以帮助我了解为什么我不断收到该警告吗?
【问题讨论】:
-
谢谢。我最初看到这篇文章,它通过索引以下代码帮助我修复了警告:
combined_updated.loc[combined_updated['institute_service']=='Less than 1 year','institute_service']=combined_updated['institute_service'][combined_updated['institute_service']=='Less than 1 year'].str.replace('Less than 1 year', '1.0')。现在的问题是我在最初问题中的代码中不断收到相同的警告。
标签: python string dataframe warnings