I have a pandas DF with a column - this column can have 3 values, either 0, 1 or ' ' (see example below). What I want to do is remove all successive numbers that are similar. So a 0 can never be followed by a 0 and a 1 can never be followed by 1. Instead I want to replace these by a ' '.
Current pandas DF
| time | value |
|---|---|
| 1:00 | 0 |
| 2:00 | |
| 3:00 | 0 |
| 4:00 | 1 |
| 5:00 | |
| 6:00 | |
| 7:00 | 1 |
| 8:00 | 1 |
| 9:00 | 0 |
What I want
| time | value |
|---|---|
| 1:00 | 0 |
| 2:00 | |
| 3:00 | |
| 4:00 | 1 |
| 5:00 | |
| 6:00 | |
| 7:00 | |
| 8:00 | |
| 9:00 | 0 |
I tried to work with loops, but cannot find a clean way to refer to 'the next same value'. Any simple solution for this?