0

What is the difference between

car_sales["Price"]=car_sales["Price"].str.replace('[\$\,\.]','')

and

car_sales["Price"]=car_sales["Price"].str.replace('[.$,]','')

after removing the escape character this code works same and fine. so, what was it's use.

  • 1
    Answer: `[.$,]` is a _character class_, and while dot and dollar sign are metacharacters, they do not need to be escaped when they appear inside a character class. So, your first version, while correct, is superflous; you don't need to escape any of those characters with backslash. – Tim Biegeleisen Aug 18 '20 at 10:31
  • thanks tim, i thought the same but you cleared – Kulbhushan Singh Aug 18 '20 at 10:42

0 Answers0