I would like to create a new column every time I get 1 in the 'Signal' column that will cast the corresponding value from the 'Value' column (please see the expected output below).
Initial data:
| Index | Value | Signal |
|---|---|---|
| 0 | 3 | 0 |
| 1 | 8 | 0 |
| 2 | 8 | 0 |
| 3 | 7 | 1 |
| 4 | 9 | 0 |
| 5 | 10 | 0 |
| 6 | 14 | 1 |
| 7 | 10 | 0 |
| 8 | 10 | 0 |
| 9 | 4 | 1 |
| 10 | 10 | 0 |
| 11 | 10 | 0 |
Expected Output:
| Index | Value | Signal | New_Col_1 | New_Col_2 | New_Col_3 |
|---|---|---|---|---|---|
| 0 | 3 | 0 | 0 | 0 | 0 |
| 1 | 8 | 0 | 0 | 0 | 0 |
| 2 | 8 | 0 | 0 | 0 | 0 |
| 3 | 7 | 1 | 7 | 0 | 0 |
| 4 | 9 | 0 | 7 | 0 | 0 |
| 5 | 10 | 0 | 7 | 0 | 0 |
| 6 | 14 | 1 | 7 | 14 | 0 |
| 7 | 10 | 0 | 7 | 14 | 0 |
| 8 | 10 | 0 | 7 | 14 | 0 |
| 9 | 4 | 1 | 7 | 14 | 4 |
| 10 | 10 | 0 | 7 | 14 | 4 |
| 11 | 10 | 0 | 7 | 14 | 4 |
What would be a way to do it?