I have a pandas dataframe like this:
Q1 | Q2 | Q3 | Q4
| 2 | |
1 | | |
| | 3 |
| 2 | |
| | | 4
My desired output is:
Q
_
2
1
3
2
4
How can I do it easily in Pandas?
>Solution :
You could use stack
df.stack().reset_index(drop=True).to_frame().rename({0:'Q'},axis=1)
Q
0 2.0
1 1.0
2 3.0
3 2.0
4 4.0