我想在我的熊猫数据框中删除空格。 我在数据框d1中使用以下代码。
cols = df1.select_dtypes(object).columns df1 [cols] = df1 [cols] .applymap(lambda x:x.strip())
但是出现以下错误:
df1 [cols] = df1 [cols] .applymap(lambda x:x.strip()) AttributeError :(““ float”对象没有属性“ strip””,“发生在索引DIV”)。
如何摆脱这种情况?