下面的代码行:df_under['Work Ratio']=df_under['Work Ratio'].astype(float)正在使用.locrow_indexer生成尝试,col_indexer = value,而不是警告。怎么摆脱它?
谢谢你的帮助
发布于 2022-11-29 14:43:59
这看起来像熊猫的数据,你想要更改“工作比率”栏的数据类型吗?警告告诉您,通过更改df_under['Work Ratio'],不会更改实际的数据格式。警告告诉您访问该列的方法是:
df_under.loc[:,'Work Ratio']=df_under['Work Ratio'].astype(float) #all rows, column 'Work Ratio'或者,您可以保存数据的数据类型。
col_types = df_under.dtypes这给你提供了一系列的熊猫类型。现在改变“工作比率”的类型
col_types['Work Ratio'] = float并将整个数据格式更改为
df_under = df_under.astype(col_types)https://stackoverflow.com/questions/74615334
复制相似问题