Panadas Condition on Dataframe returns TypeError: '>' not supported between instances of 'str' and 'int'
问题 I'm working on a DataFrame using pandas and I need to add a new column based on some conditions. My DataFrame is: discount tax total subtotal productid 3 0 20 13 002 10 3 106 94 003 46.49 6 21 20 004 I need to apply some conditions while adding a new column named as Class to the DataFrame. Conditions are as follows: IF discount > 20 & total > 100 & tax == 0 then Class should be 1 otherwise it should be 0 Here's how I have tried: def conditions(s): if (s['discount'] > 20) and (s['tax'] == 0)