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

0 votes
1 answer
0 votes
1 answer
+2 votes
2 answers
asked May 25, 2019 in Python by Shubham (3.9k points)

Browse Categories

...