Create new column based on condition on other categorical column
问题 I have a dataframe as shown below Category Value A 10 B 22 A 2 C 30 B 23 B 4 C 8 C 24 A 9 I need to create a Flag column Flag based following conditions If the values of Category A is greater than or equal 5 then Flag=1, else 0 If the values of Category B is greater than or equal 20 then Flag=1, else 0 If the values of Category C is greater than or equal 25 then Flag=1, else 0 Expected output as shown below Category Value Flag A 10 1 B 22 1 A 2 0 C 30 1 B 23 1 B 4 0 C 8 0 C 24 0 A 9 1 I tried