Python numpy, here's the question

Asked 2 years ago, Updated 2 years ago, 20 views

I from itertools import permutations a=permutations(['1','4','5','6','7','9'],6)

This was done to obtain the results of a batch (by 6!) consisting of 1,4,5,6,7,9

I'm going to do this with numpy. But I don't know how to get it listed on numpy I'd appreciate it if you let me know

python

2022-09-22 15:19

1 Answers

from itertools import permutations
import numpy as np

a=permutations(['1','4','5','6','7','9'],6)
b = np.array(list(a))

In [29]: b
Out[29]:
array([['1', '4', '5', '6', '7', '9'],
       ['1', '4', '5', '6', '9', '7'],
       ['1', '4', '5', '7', '6', '9'],
       ...,
       ['9', '7', '6', '4', '5', '1'],
       ['9', '7', '6', '5', '1', '4'],
       ['9', '7', '6', '5', '4', '1']],
      dtype='<U1')

Are you talking about this?


2022-09-22 15:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.