I have a pyspark.sql.dataframe.DataFrame with four columns of strings such as:
| id | col1 | col2 | col3 |
|---|---|---|---|
| z10234 | Header One : teacher | Header Two : salary | Header Three : 12 |
| z10235 | Header One : plumber | Header Two : hourly | Header Three : 15 |
| z10236 | Header One : executive | Header Two : salary | Header Three : 17 |
| z10237 | Header One : teacher | Header Two : salary | Header Three : 15 |
| z10238 | Header One : manager | Header Two : hourly | Header Three : 11 |
I need to convert each string col1, col2, and col3 such that the initial part of the string becomes the header:
| id | HeaderOne | HeaderTwo | HeaderThree |
|---|---|---|---|
| z10234 | teacher | salary | 12 |
| z10235 | plumber | hourly | 15 |
| z10236 | executive | salary | 17 |
| z10237 | teacher | salary | 15 |
| z10238 | manager | hourly | 11 |