mardi 19 novembre 2019

How can i create a new column with values under condition

I have three relevant columns: time, id, and interaction. How can i create a new column with the id values that have a '1' in column 'interaction' in the given time window?

Should look something like this:

time   id   vec_len  quadrant   interaction    Paired with

1    3271    0.9    7   0 
1    3229    0.1    0   0
1    4228    0.5    0   0
1    2778   -0.3    5   0
2    4228    0.2    0   0
2    3271    0.1    6   0
2    3229    -0.7   5   1    [2778, 4228]
2    3229    -0.3   2   0
2    4228    -0.8   5   1    [2778, 3229]
2    2778   -0.6    5   1    [4228, 3229]
3    4228    0.2    0   0
3    3271    0.1    6   0
3    4228    -0.7   5   1    [3271]
3    3229    -0.3   2   0
3    3271    -0.8   5   1    [4228]

Thank you for helping!!

Aucun commentaire:

Enregistrer un commentaire