我有以下 numpy 数组:
import numpy as np
pair_array = np.array([(205, 254), (205, 382), (254, 382), (18, 69), (205, 382),
(31, 183), (31, 267), (31, 382), (183, 267), (183, 382)])
print(pair_array)
#[[205 254]
# [205 382]
# [254 382]
# [ 18 69]
# [205 382]
# [ 31 183]
# [ 31 267]
# [ 31 382]
# [183 267]
# [183 382]]
Run Code Online (Sandbox Code Playgroud)
有没有办法将此数组转换为包含所有可能组合的出现次数的对称熊猫数据框?我期待这样的事情:
# 18 31 69 183 205 254 267 382
# 18 0 0 1 0 0 …Run Code Online (Sandbox Code Playgroud)