如何从熊猫的给定数据框列中获取唯一对

时间:2020-02-04 11:24:48

标签: python pandas data-science

sample data from dataframe

(8, 8), (8, 8), (8, 8), (8, 8), (8, 8)
(6, 7), (7, 7), (7, 7), (7, 6), (6, 7)
(2, 12), (12, 3), (3, 4), (4, 12), (12, 12)

    ```
    
        new_col = []
            for e in content.Pairs:
            new_col.append(list(dict.fromkeys(e)))
            content['Unique'] = new_col
    
    ```

期望的输出是像这样的“配对”列中的唯一对

(8, 8),(6, 7),(7, 6),(7, 7),(2, 12) so on

尝试上面的代码时,我得到的是这个结果

唯一

['8', '']
['6', '7', '']
['2', '12', '3', '4', '']

0 个答案:

没有答案