1

I have a dataframe which has four columns, I want to add a fifth column based on the values of an exisitng column, I want to add a column, let us name it "A", and the conditions should be like that, when angle =(0:90), so A=1, when angle =(180:270), so A=2, else, so A=NA

df
fromnode  vianode  tonode   angle
  36        1       120     140
  36        3       56      190
  40        67      145     75
  40        33      43      250
  .         .        .       .
  .         .        .       .
 345       185      456      290

so the final output should be like that

fromnode  vianode  tonode   angle    A
  36         1       120     140     NA
  36         3       56      190     2
  40         67      145     75      1  
  40         33      43      250     2 
  .          .       .       .
  .          .       .       .
 345        185     456     290     NA
moataz ali
  • 21
  • 4

0 Answers0