0 votes
1 view
in Data Science by (13.1k 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 (19.9k points)

Using vectorised str method replace:

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

df

Output:

      range

0    (2-30)

1  (50-290)

...