iSerd
iSerd

Reputation: 178

How To Remove \x95 chars from text - Pandas?

I am having trouble to remove a space at the beginning of string in pandas dataframe cells. If you look at the dataframe cells, it seems like that there is a space at the start of string however it prints "\x95 12345" when you output one of cells which has set of chars at the beginning, so as you can see it is not a normal space char but it is rather "\x95"

I already tried to use strip() - But it didn't help.

Dataframe was produced after the use of str.split(pat=',').tolist() expression which basically split the strings into different cells by ',' so now my strings have this char added.

Upvotes: 0

Views: 754

Answers (1)

meW
meW

Reputation: 3967

Assuming col1 is your first column name:

import re
df.col1 = df.col1.apply(lambda x: re.sub(r'\x95',"",x))

Upvotes: 2

Related Questions