I have a dataframe that looks like below
| ColName |
|---|
| a |
| b |
| c |
| d |
| e |
| f |
| g |
| h |
| i |
| j |
| k |
| l |
and based on an specific parameter I want to transpose those values into rows. So for example if the parameter value is 3, the new dataframe will look like below
| Col1 | Col2 | Col3 |
|---|---|---|
| a | b | c |
| d | e | f |
| g | h | i |
| j | k | l |
However if the parameter value is 4, it will look like below
| Col1 | Col2 | Col3 | Col4 |
|---|---|---|---|
| a | b | c | d |
| e | f | g | h |
| i | j | k | l |
A few things to notice:
- The column names are not important
- Both the number of items in that single column and the parameter can change
Any idea how to achieve this in pyspark? Thanks in advance.