Home > other >  How to use UDF function on the pandas dataframe?
How to use UDF function on the pandas dataframe?

Time:03-04

I have a pandas data frame I need to apply the clean rule on the name column so that the name only consists of the string value, not the numerical value but I need to do that using a UDF. SO I have created a UDF and then applied it on the name column of my data frame but I am not getting the desired result. Sharing some screenshots of my code and the output. Please, anyone, guide me once. This image is my code screenshot.

CodePudding user response:

You should modify remove_num function, then it will work.

import re
def remove_num(emp_name):
    remove_val = re.sub("[0-9]", "", emp_name)
    return remove_val
  • Related