Home > Notes > Python Pandas

pandas user define functions

pandas user define functions

pandas user define functions

using apply(), we create the User define Function.

def checkvalue(id1):
  if(id1>3):
    return "Greater Than 3"
  elif(id1<3)  :
    return "Lesser Than 3"
  else:
    return "equals to 3"
 #df['new_column']=column_nameapply(function_)name
 df['value1'] = df['id'].apply(checkvalue)
 print(df)