我在数据框中有多个列/值,并且我想进行正态性测试。
所以我需要在单列中获取所有值。
我已经尝试过stack()和to_numpy()函数,但是它们返回多个数组。
df.stack()
0 1 -0.138904
2 -0.819545
3 -0.765260
4 -0.035203
5 0.147615
...
222 55 -0.407228
56 -0.357614
57 -0.455689
58 -0.083255
59 -0.334126
Length: 13157, dtype: float64
df.to_numpy()
array([[-0.13890365, -0.81954507, -0.76525984, ..., -0.07031505,
-0.51522276, -0.33187401],
[ 0.1606656 , 0.01011122, -0.01753616, ..., 0.14043105,
0.2430155 , -0.03276516],
[-0.37554229, -0.05746348, -0.46619369, ..., -0.51693021,
-0.34434628, -0.22732171],
...,
[-0.0315992 , -0.58995652, -0.35898007, ..., 0.00513196,
-0.69495718, 0.04492633],
[-0.8875676 , -0.71248811, -0.67634478, ..., -0.95588916,
-0.91959176, -0.93648983],
[-0.09563407, -0.27279773, 0.06991731, ..., -0.45568943,
-0.08325458, -0.33412561]])
我需要像这样的单列:
1.114169
0.780083
0.843903
-0.193405
-0.192596
-0.234779
答案 0 :(得分:1)
与to_numpy
进行stack
连锁时
a = df.stack().to_numpy()