Get all combinations of elements from two lists?

use product from itertools:

>>> from itertools import product
>>> pd.DataFrame(list(product(l1, l2)), columns=['l1', 'l2'])
  l1  l2
0  A   1
1  A   2
2  B   1
3  B   2

Leave a Comment