Docy

pandas user define functions

Estimated reading: 1 minute 829 views

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)
				
			

Leave a Comment

Share this Doc
CONTENTS