I have a panda
data frame as below.
|Col_A |Col_B |Col_C|
|--------|--------|-----|
| 1470 | 31 |687 |
| NaN | 51 |689 |
| NaN | 85 |690 |
| 1470 | 78 |691 |
| NaN | 64 |692 |
| NaN | 78 |693 |
| NaN | 45 |694 |
| 1471 | 87 |697 |
I need to obtain a data set, where all the values in Col_C
will be removed (null) based on a condition of Col_A
. The condition will be, only when the two consecutive values of column A will be different (example 1470 and 1471) the corresponding value of Col_C
will be NaN
The datasets outcome that I want is:
|Col_A |Col_B |Col_C|
|--------|--------|-----|
| 1470 | 31 |687 |
| NaN | 51 |689 |
| NaN | 85 |690 |
| 1470 | 78 |691 |
| NaN | 64 |NaN |
| NaN | 78 |NaN |
| NaN | 45 |NaN |
| 1471 | 87 |697 |
Any help will be highly appreciated.