Find min value in column until value not changed in another value Pandas
Question:
I have a data frame:
| Col1 | Col2 | Col3 |
|------|------|------|
| 1 | A | 6 |
| 2 | A | 3 |
| 3 | B | 12 |
| 4 | B | 10 |
| 5 | A | 12 |
| 6 | A | -12 |
| 7 | A | 31 |
I want to find min value until a value not changed in Col2, I used Groupby
but found out its wrong,
desired df:
| Col1 | Col2 | Col3 |
|------|------|------|
| 2 | A | 3 |
| 4 | B | 10 |
| 6 | A | -12 |
Answers:
I have a data frame:
| Col1 | Col2 | Col3 |
|------|------|------|
| 1 | A | 6 |
| 2 | A | 3 |
| 3 | B | 12 |
| 4 | B | 10 |
| 5 | A | 12 |
| 6 | A | -12 |
| 7 | A | 31 |
I want to find min value until a value not changed in Col2, I used Groupby
but found out its wrong,
desired df:
| Col1 | Col2 | Col3 |
|------|------|------|
| 2 | A | 3 |
| 4 | B | 10 |
| 6 | A | -12 |