I have a dataframe in which one columns values are lists of strings.
I want to remove the leading and trailing white space from each of the elements in the lists.
I am trying this:
interests_no_nulls = fcc['JobRoleInterest'].dropna()
splitted_interests = interests_no_nulls.str.split(',')
splitted_interests.apply(lambda x: x.strip())
But I get this:
Traceback (most recent call last):
File "C:\Users\Mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\series.py", line 4045, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas/_libs/lib.pyx", line 2228, in pandas._libs.lib.map_infer
File "C:/Users/Mark/PycharmProjects/main/main.py", line 60, in <lambda>
splitted_interests.apply(lambda x: x.strip())
AttributeError: 'list' object has no attribute 'strip'
Notice the leading or trailing white space in some of the list elements:
