Unpack NumPy array by column

前端 未结 3 1564
天命终不由人
天命终不由人 2021-01-03 23:12

If I have a NumPy array, for example 5x3, is there a way to unpack it column by column all at once to pass to a function rather than like this: my_func(arr[:, 0], arr[

3条回答
  •  旧巷少年郎
    2021-01-03 23:45

    I guess numpy.split will not suffice in the future. Instead, it should be

    my_func(tuple(numpy.split(array, 3, 1)))
    

    Currently, python prints the following warning:

    FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.

提交回复
热议问题