Unpack NumPy array by column

前端 未结 3 1565
天命终不由人
天命终不由人 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:47

    numpy.split splits an array into multiple sub-arrays. In your case, indices_or_sections is 3 since you have 3 columns, and axis = 1 since we're splitting by column.

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

提交回复
热议问题