numpy - Python SciPy Possible cases of n choose k -


a = [1, 2, 3, 4, 5, 6] # or ! = ['one', 'two', 'three', 'four', 'five', 'six'] 

in situation, want know possible combinations; choose k elements among a. if use b = scipy.misc.comb(a, 1), shows:

b = [1, 2, 3, 4, 5, 6] 

where bi ai choose 1. , doesn't work if a array of strings.

what wanted is:

b = [[1], [2], [3], [4], [5], [6]] # or ! b = [['one'], ['two'], ['three'], ['four'], ['five'], ['six']] 

which means, possible set of 1 chosen element among elements in array a

it easy if use matlab. i'm trying use scipy stack.

any reason using scipy , not itertools particular problem?

looking itertools.combinations or itertools.permutations may provide more adequate solution.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -