import itertools
values = carton.values[:, 1:]
combi = [np.column_stack([x,y,z])
for x, y, z in itertools.permutations([values[:,0],values[:,1],values[:,2]])]
new_values = np.concatenate(combi)
new_index = carton.carton_id.tolist() * len(combi)
new = np.column_stack([new_index, new_values])
new_carton = pd.DataFrame(new, columns=['carton_id', 'length', 'width', 'height'])
df = pd.merge(product, new_carton, how='cross', suffixes=('_prod', '_cart'))
df = df[(df.length_cart>df.length_prod)
& (df.width_cart>df.width_prod)
& (df.height_cart>df.height_prod)]
df = df[['product_id', 'carton_id']].drop_duplicates()
print(df)
product_id carton_id
0 100 66
1 100 67