what I have been trying to do is strip all the string columns in a number of dataframes using a function Here's the code
def stripped_data(data):
data=data.apply(lambda x: x.str.strip() if x.dtype=="object" else x)
return data
then I am trying to pass multiple tables in the same function using locals() dictionary
for i in files_new:
locals()[i]=stripped_data(locals()[i])
here files_new is the list containing the names of the tables but this is the error- "Can only use .str accessor with string values!"
but this code individually works fine without any error
data=data.apply(lambda x: x.str.strip() if x.dtype=="object" else x)
where data is the name of any table