如何转换数据帧,如:
df =
0 1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 NaN NaN NaN NaN NaN NaN
7 8 9 10 11 12 NaN NaN NaN NaN NaN NaN
13 14 15 16 17 18 NaN NaN NaN NaN NaN NaN
完全像这样的列表(跳过NaN):
df_list =
[array([[ 1, 2],
[ 3, 4],
[ 5, 6]]), array([[ 7, 8],
[ 9, 10],
[ 11, 12]]), array([[ 13, 14],
[ 15, 16],
[ 17, 18]])]
我已经尝试过df1.values.tolist()
,但它并没有给我夫妻
答案 0 :(得分:1)
指定每个组中需要多少个项目,并使用FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDevDebugGoogleServices'.
> No matching client found for package name 'com.***.*****.*********.dev'
的{{1}}
numpy
reshape
答案 1 :(得分:0)
要与您的确切输出匹配:
[df.loc[i].to_numpy().reshape(-1,2) for i in df.index]
输出:
[array([[1, 2],
[3, 4],
[5, 6]], dtype=int64), array([[ 7, 8],
[ 9, 10],
[11, 12]], dtype=int64), array([[13, 14],
[15, 16],
[17, 18]], dtype=int64)]