gpt4 book ai didi

python - 相当于 itertools.product 的 Numpy

转载 作者:太空狗 更新时间:2023-10-29 20:51:45 28 4
gpt4 key购买 nike

<分区>

我知道 itertools.product 可以迭代多个维度的关键字列表。例如,如果我有这个:

categories = [
[ 'A', 'B', 'C', 'D'],
[ 'E', 'F', 'G', 'H'],
[ 'I', 'J', 'K', 'L']
]

我在上面使用 itertools.product(),我有类似的东西:

>>> [ x for x in itertools.product(*categories) ]
('A', 'E', 'I'),
('A', 'E', 'J'),
('A', 'E', 'K'),
('A', 'E', 'L'),
('A', 'F', 'I'),
('A', 'F', 'J'),
# and so on...

对于 numpy 的数组,是否有一种等效的、直接的方法来做同样的事情?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com