Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have a column in my dataframe like this:

range

(2,30)

(50,290)

(400,1000)

... 

and I want to replace the ',' comma with '-' dash. I am currently using this method but nothing is changed.

org_info_exc['range'].replace(',','-',inplace=True)

Can anybody help?

1 Answer

0 votes
by (41.4k points)

Using vectorised str method replace:

df['range'] = df['range'].str.replace(',','-')

df

Output:

      range

0    (2-30)

1  (50-290)

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...