hasangzc
hasangzc

Reputation: 63

unwanted characters in pandas dataframe column

I want to delete "\n" and "[" characters from jobDescription column in dataframe. I try this code. But it s not working data['jobDescription'] = data['jobDescription'].str.replace(r'\n',' ', regex=True)

you can see the df in the picture below; enter image description here

how do i solve this problem? Thanks.

Upvotes: 0

Views: 173

Answers (1)

Wickkiey
Wickkiey

Reputation: 4642

You can make use of python regular expression.

import re

data.jobDescription.apply(lambda x : ''.join(re.findall("[a-zA-Z0-9 ]",text)))

The regex pattern will only allow alphabets and numbers, if you want to include symbols, you can add in the pattern to achieve that.

Upvotes: 1

Related Questions