回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>现在有很多类似的问题,但大多数都回答了如何删除重复的列。但是,我想知道如何制作一个元组列表,其中每个元组都包含重复列的列名。我假设每个列都有一个唯一的名称。为了进一步说明我的问题:</p>
<pre><code>df = pd.DataFrame({'A': [1, 2, 3, 4, 5],'B': [2, 4, 2, 1, 9],
'C': [1, 2, 3, 4, 5],'D': [2, 4, 2, 1, 9],
'E': [3, 4, 2, 1, 2],'F': [1, 1, 1, 1, 1]},
index = ['a1', 'a2', 'a3', 'a4', 'a5'])
</code></pre>
<p>然后我要输出:</p>
^{pr2}$
<p>如果你今天感觉很好,那么也可以把同样的问题扩展到行。如何获取每个元组包含重复行的元组列表。在</p>