问题描述
我一直试图做的是使用函数去除许多数据帧中的所有字符串列 这是代码
def stripped_data(data):
data=data.apply(lambda x: x.str.strip() if x.dtype=="object" else x)
return data
然后我尝试使用 locals() 字典在同一个函数中传递多个表
for i in files_new:
locals()[i]=stripped_data(locals()[i])
这里的 files_new 是包含表名称的列表 但这是错误-“只能使用带有字符串值的 .str 访问器!”
data=data.apply(lambda x: x.str.strip() if x.dtype=="object" else x)
其中数据是任何表的名称
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)