Answers for "python lambda 2 columns"

3

lambda with two columns pandas

tp['col'] = tp.apply(lambda row: row['source'] if row['target'] in ['b', 'n'] else 'x',
                     axis=1)
Posted by: Guest on August-11-2020
0

apply lambda function to multiple columns pandas

df['new_col'] = df.apply(lambda x: some_func(x['col1'], x['col2']))
Posted by: Guest on November-19-2021

Python Answers by Framework

Browse Popular Code Answers by Language