I\'m reading a CSV file into a DataFrame. I need to strip whitespace from all the stringlike cells, leaving the other cells unchanged in Python 2.7.
Here is what I\
This worked for me - applies it to the whole dataframe:
def panda_strip(x): r =[] for y in x: if isinstance(y, str): y = y.strip() r.append(y) return pd.Series(r) df = df.apply(lambda x: panda_strip(x))