Answers for "pandas apply function on two columns"

1

pandas apply function on two columns

def stream_half(col1, col2):
    if col1 == 'desktop':
        return col2/2
    else:
        return int(col2)
        
df['clean'] = df.apply(lambda row: stream_half(row['device'], 
  row['streams']), axis = 1)
Posted by: Guest on March-30-2022

Code answers related to "pandas apply function on two columns"

Python Answers by Framework

Browse Popular Code Answers by Language