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

时间:2018-05-18 22:27:34   收藏:0   阅读:2439
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")

  

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!