I have pandas DF that has many string elements that contain words like this:
'Frost '
Which has many leading white spaces in front of it. When I compare this line with:
'Frost'
I realized that the comparison was False due to leading spaces.
Although I can solve this, iterating over each element of pandas DF, the process is slow due to the large number of records that I have.
This other approach should work, but it does not work:
rawlossDF['damage_description'] = rawlossDF['damage_description'].map(lambda x: x.strip(''))
So when I check the element:
rawlossDF.iloc[0]['damage_description']
It returns:
'Frost '
What's going on here?
source share