I want to add a column to my dataframe (with repetitive values) which contains the name of previous group (float and sortable). any idea?
Before:
| Group | value |
|---|---|
| 1.1 | value1 |
| 1.1 | value2 |
| 1.1 | value3 |
| 1.1 | value3 |
| 1.2 | value4 |
| 1.2 | value4 |
| 1.2 | value5 |
After:
| Group | value | Previous Group |
|---|---|---|
| 1.1 | value1 | Nan |
| 1.1 | value2 | value1 |
| 1.1 | value3 | value2 |
| 1.1 | value3 | value2 |
| 1.2 | value4 | Nan |
| 1.2 | value4 | Nan |
| 1.2 | value5 | Value4 |