AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas

test_behavior_A["var3"]=test_behavior_A["var3"].str.strip("M").astype("float")

  上述代码改为:

test_behavior_A["var3"]=test_behavior_A["var3"].astype(str).strip("M").astype("float")

  

文章来自:https://www.cnblogs.com/xiaodongsuibi/p/9058050.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3