list = [
['aa1','aa2'],
['bb1','bb2','bb3'],
['cc1','cc2','cc3','cc4',],
]
for a in list[0]:
for b in list[1]:
for c in list[2]:
<что-то делаем>
import itertools
lst = [
['aa1','aa2'],
['bb1','bb2','bb3'],
['cc1','cc2','cc3','cc4',],
]
for item in itertools.product(*lst):
# do stuff
print item
>>>
('aa1', 'bb1', 'cc1')
('aa1', 'bb1', 'cc2')
('aa1', 'bb1', 'cc3')
('aa1', 'bb1', 'cc4')
('aa1', 'bb2', 'cc1')
('aa1', 'bb2', 'cc2')
('aa1', 'bb2', 'cc3')
('aa1', 'bb2', 'cc4')
('aa1', 'bb3', 'cc1')
('aa1', 'bb3', 'cc2')
('aa1', 'bb3', 'cc3')
('aa1', 'bb3', 'cc4')
('aa2', 'bb1', 'cc1')
('aa2', 'bb1', 'cc2')
('aa2', 'bb1', 'cc3')
('aa2', 'bb1', 'cc4')
('aa2', 'bb2', 'cc1')
('aa2', 'bb2', 'cc2')
('aa2', 'bb2', 'cc3')
('aa2', 'bb2', 'cc4')
('aa2', 'bb3', 'cc1')
('aa2', 'bb3', 'cc2')
('aa2', 'bb3', 'cc3')
('aa2', 'bb3', 'cc4')
print [(x,y) for x in list[0] for y in list[1]]
>> [('aa1', 'bb1'), ('aa1', 'bb2'), ('aa1', 'bb3'), ('aa2', 'bb1'), ('aa2', 'bb2'), ('aa2', 'bb3')]
tab={'a1':['aa1','aa2'],
'b1':['bb1','bb2','bb3'],
'c1':['cc1','cc2','cc3','cc4',]}
for key in tab:
row=tab[key]
for el in row:
print(el)
import pandas as pd
l = [
['aa1','aa2'],
['bb1','bb2','bb3'],
['cc1','cc2','cc3','cc4',],
]
df=pd.DataFrame(l)
print(df)
#Выведет
0 1 2 3
0 aa1 aa2 None None
1 bb1 bb2 bb3 None
2 cc1 cc2 cc3 cc4
print(df[0])
#Выведет
0 aa1
1 bb1
2 cc1