擅长:python、mysql、java
<p>您可以使用来自<code>itertools</code>的<code>combinations</code>循环行和列,并添加到列表中。你知道吗</p>
<pre><code>from itertools import combinations
explode_list = []
_ = [explode_list.append([r + c, df.loc[r][c]]) for r, c in combinations(df.columns, 2)]
</code></pre>
<p><strong>输出</strong></p>
<pre><code>[['AB', 1],
['AC', 0],
...
]
</code></pre>