Reputation: 230
I'm looking for all 5 rows combinations of a dataframe. code:
from itertools import combinations
for index, row in combinations(df_new.iterrows(), 5):
input(row)
Output what I'm looking for:
row[0], row[1], row[2], row[3], row[4]
row[0], row[1], row[2], row[3], row[5]
row[0], row[1], row[2], row[3], row[6]
row[0], row[1], row[2], row[3], row[7]
row[0], row[1], row[2], row[3], row[8]
......................................
row[0], row[4], row[5], row[6], row[7]
row[0], row[4], row[5], row[6], row[8]
row[0], row[4], row[5], row[6], row[9]
row[0], row[4], row[5], row[6], row[10]
row[0], row[4], row[5], row[6], row[11]
......................................
row[5], row[6], row[7], row[8], row[9]
row[5], row[6], row[7], row[8], row[10]
row[5], row[6], row[7], row[8], row[11]
row[5], row[6], row[7], row[8], row[12]
row[5], row[6], row[7], row[8], row[13]
dataframe:
index Date Open High Low Close Adj Close Close_status
1 1 2018-01-03 172.529999 174.550003 171.960007 172.229996 166.774963 MIN
3 3 2018-01-05 173.440002 175.369995 173.050003 175.000000 169.457214 MAX
6 6 2018-01-10 173.160004 174.300003 173.000000 174.289993 168.769714 MIN
Upvotes: 1
Views: 57
Reputation: 173
It works:
for row in combinations(df_new.values, 5):
input(row)
Upvotes: 1