Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To separate two values in a single column of a numpy array, you can use the numpy "split" function.

For example, let's say you have an array "a" with two values in each row:

import numpy as np

a = np.array([[1, 2], [3, 4], [5, 6]])

To separate the two values in each row into separate columns, you can use the split function along the second axis:

a_split = np.split(a, 2, axis=1)

This will create a new array "a_split" with two columns, each containing one of the original values:

array([[[1],
        [3],
        [5]],

       [[2],
        [4],
        [6]]])