Stripping all trailing empty spaces in a column of a pandas dataframe

前端 未结 2 1459
别那么骄傲
别那么骄傲 2021-02-04 08:26

I have a pandas DF that has many string elements that contains words like this:

\'Frost                              \'
         


        
2条回答
  •  自闭症患者
    2021-02-04 08:52

    Replace your function with this:

    rawlossDF['damage_description'] = rawlossDF['damage_description'].map(lambda x: x.strip())
    

    You almost had it right, you needed to get rid off the '' inside strip()

提交回复
热议问题