Home > Software design >  How do I rewrite a function as a lambda function using pandas?
How do I rewrite a function as a lambda function using pandas?

Time:09-21

I have a function:

def function(x):
    return x > 0
data['number'] = data['arr_nums'].apply(function)

How do I rewrite this as a lambda function by using pandas? Thanks!

CodePudding user response:

e = lambda a: a>0
print(e(13))e = lambda a: a>0
print(e(13))

you can use like this. If you found it useful, I would appreciate it if you support it :)

CodePudding user response:

Very simple solution:

function = lambda a : a > 0
data['number'] = function(data['arr_nums'])
  • Related