将宽数据框重塑为单列

Reshape wide datafame into a single column

我有一个很长的数据框,例如:

    1   2   3 ... 109
    1   2   3 ... 109
    1   2   3 ... 109
    .   .   . ... ...
   109 109 109... 109

并且我希望将所有内容都放在一栏中,如下所述:

1
1
1
2
2
2
3
3
3
...
109

我尝试将数据框转换为 numpy 数组以供使用:

arr_y = np.arange(11881).reshape(11881,1)

但是没用。它给了我一个垂直列(没关系)但是从 0,1,2,3,4 .. 到 11881 (=109*109).

知道怎么做吗?

在 pandas DataFrame 中执行以下操作:

import pandas as pd
df = pd.DataFrame({'Col1': [1,1,1], 'Col2': [2,2,2],'Col3': [3,3,3],'Col109': [109,109,109]})
df = pd.DataFrame(df.values.ravel('F'))