Stripping all trailing empty spaces in a column of a pandas dataframe
I have a pandas DF that has many string elements that contains words like this: 'Frost ' Which has many leading white spaces in front of it. When I compare this string to: 'Frost' I realized that the comparison was False due to the leading spaces. Although I can solve this by iterating over every element of the pandas DF, the process is slow due to the large number of records I have. This other approach should work, but it is not working: rawlossDF['damage_description'] = rawlossDF['damage_description'].map(lambda x: x.strip('')) So when I inspect an element: rawlossDF.iloc[0]['damage