I have just started with python and need some help. I have a dataframe which looks like "Input Data", What I want is stack by every nth column. In other words, I want a dataframe where every nth Column is appended below to first m rows
id | city | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6 | Col 7 | Col 8 | Col 9 | Col 10 |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 51 | 155 | 255 | 355 | 455 | 666 | 777 | 955 | 55 | 553 |
2 | 0 | 52 | 155 | 255 | 355 | 455 | 666 | 777 | 595 | 55 | 553 |
3 | NAN | 53 | 155 | 255 | 355 | 455 | 666 | 777 | 559 | 55 | 535 |
4 | 1 | 54 | 155 | 255 | 355 | 545 | 666 | 777 | 559 | 55 | 535 |
5 | 7 | 55 | 155 | 255 | 355 | 455 | 666 | 777 | 955 | 55 | 535 |
Required Output
id | city | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 |
---|---|---|---|---|---|---|
1 | 1 | 51 | 155 | 255 | 355 | 455 |
2 | 0 | 52 | 155 | 255 | 355 | 455 |
3 | NAN | 53 | 155 | 255 | 355 | 455 |
4 | 1 | 54 | 155 | 255 | 355 | 545 |
5 | 7 | 55 | 155 | 255 | 355 | 455 |
1 | 1 | 666 | 777 | 955 | 55 | 553 |
2 | 0 | 666 | 777 | 595 | 55 | 553 |
3 | NAN | 666 | 777 | 559 | 55 | 535 |
4 | 1 | 666 | 777 | 559 | 55 | 535 |
5 | 7 | 666 | 777 | 955 | 55 | 535 |
I am trying to do something opposite of this