-3

Unable to convert every '-' into blank space.

dataset = ['0000sh--_dsd' , '0000sd---_dsd' , '000ad-_512']
test1 = pd.DataFrame(dataset)

I tried this `test1.replace('-',' ',regex=True)

Input: 0000sh--_dsd

I need this as Output: 0000sh _dsd (which is not happening)

Python is not allowing to convert to space. Please advise how to sort out this situation.

0

1 Answer 1

-1

Sorry I realised to late it's a dataframe In this case I would just solve it like this

dataset = ['0000sh--_dsd', '0000sd---_dsd', '000ad-_512']
dataset = [line.replace("-", "") for line in dataset]
test1 = pd.DataFrame(dataset)

Ignore my first answer below


Strings in Python are immutable so you need to use this

test1 = test1.replace('-', '')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.