我有一个包含列' flow1,flow2,flow3'的数据框。 我需要从列中提取不同的订单。
df1 = pd.read_csv("Desktop/lab9/cleaning1/1160/flow.tsv", sep = "\t", header = None, na_values=[" "])
df1.columns = ['flow1', 'flow2', 'flow3']
for p in permutations(df1.columns, 3):
print p
这是给我的
('flow1', 'flow2', 'flow3')
('flow1', 'flow3', 'flow2')
('flow2', 'flow1', 'flow3')
('flow2', 'flow3', 'flow1')
('flow3', 'flow1', 'flow2')
('flow3', 'flow2', 'flow1')
但我只需要:
('flow1', 'flow2', 'flow3')
('flow1', 'flow3', 'flow2')
('flow2', 'flow3', 'flow1')
答案 0 :(得分:0)
你误解了数学运算符。
使用from itertools import combinations
代替permutations