regex replace cpf 1

regex replace cpf

str.replace(/\.|\-/g, "");

Here is what the above code is Doing:
1. We’re using the .apply() method to apply a function to each row in the ‘phone_number’ column.
2. The function we’re applying is lambda x: x.str.replace(…).
3. The .str.replace() method is used to replace all instances of a pattern in a string with another string.
4. The pattern we’re replacing is either a period (.) or a hyphen (-).
5. The string we’re replacing it with is an empty string (“”).
6. The .replace() method returns a new string, so we assign it back to the ‘phone_number’ column.

Similar Posts