I'm still relatively new to Python. I have data that has come in a csv like this
| ID | Postcode | Status | Date | Value |
|---|---|---|---|---|
| 1 | E1 2QJ | sold | June 2022 | 1000000 |
| 1 | E1 2QJ | listed | February 2022 | 900000 |
| 1 | E1 2QJ | sold | June 2018 | 850000 |
| 2 | E2 3JJ | sold | January 2022 | 1250000 |
| 2 | E2 3JJ | listed | October 2021 | 1000000 |
| 3 | E3 4IQ | listed | July 2022 | 900000 |
| 4 | E4 8RJ | sold | March 2021 | 850000 |
I would like it to look like this:
| ID | Postcode | Status | Date | Value | Status1 | Date1 | Value1 | Status2 | Date2 | Value2 |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | E1 2QJ | sold | Jun 2022 | 1000000 | listed | Feb 2022 | 900000 | sold | June 2018 | 850000 |
| 2 | E2 3JJ | sold | Jan 2022 | 1250000 | listed | Oct 2021 | 1000000 | NaN | NaN | NaN |
| 3 | E3 4IQ | listed | Jul 2022 | 900000 | NaN | NaN | NaN | Nan | NaN | NaN |
| 4 | E4 8RJ | sold | Mar 2021 | 850000 | NaN | NaN | NaN | Nan | NaN | NaN |
Does anyone know what is the best way to do this?