Transpose, then unpack:

>>> x, y, z = data.T
>>> x
array([1, 4, 7])
Answer from behzad.nouri on Stack Overflow
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.hsplit.html
numpy.hsplit โ€” NumPy v2.5 Manual
Split an array into multiple sub-arrays horizontally (column-wise). Please refer to the split documentation. hsplit is equivalent to split with axis=1, the array is always split along the second axis except for 1-D arrays, where it is split at axis=0. ... Split an array into multiple sub-arrays of equal size. ... Try it in your browser! >>> import numpy as np >>> x = np.arange(16.0).reshape(4, 4) >>> x array([[ 0., 1., 2., 3.], [ 4., 5., 6., 7.], [ 8., 9., 10., 11.], [12., 13., 14., 15.]]) >>> np.hsplit(x, 2) [array([[ 0., 1.], [ 4., 5.], [ 8., 9.], [12., 13.]]), array([[ 2., 3.], [ 6., 7.], [10., 11.], [14., 15.]])] >>> np.hsplit(x, np.array([3, 6])) [array([[ 0., 1., 2.], [ 4., 5., 6.], [ 8., 9., 10.], [12., 13., 14.]]), array([[ 3.], [ 7.], [11.], [15.]]), array([], shape=(4, 0), dtype=float64)]
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_split.asp
NumPy Splitting Array
Use the hsplit() method to split the 2-D array into three 2-D arrays along columns. import numpy as np arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) newarr = np.hsplit(arr, 3) print(newarr) Try it ...
Discussions

python - Split a numpy column into two columns and keep them in the original array - Stack Overflow
I have a numpy array, which has 3 columns. There are 100,000 rows, but here are the first two: burger flipper part time 12-5.00 spam flipper full time 98-10.00 The problem is, the job cod... More on stackoverflow.com
๐ŸŒ stackoverflow.com
August 20, 2019
Split a 2d NumPy array into 2 separate 2d arrays based on a column value
np.split isn't doing what you think it's doing and you don't need it for this. To split an original array x into two subarrays a and b the way you want, you can simply do this: x = np.array([[1, 2, 4], [1, 4, 4], [2, 2, 4], [2, 5, 9]]) a = x[x[:, 0] == 1] b = x[x[:, 0] == 2] More on reddit.com
๐ŸŒ r/AskProgramming
2
1
October 19, 2020
numpy - python column split - Stack Overflow
The OP mentioned array, so it makes sense to bring up numpy. More on stackoverflow.com
๐ŸŒ stackoverflow.com
numpy - Python: separate matrix by column values - Stack Overflow
I want to create two separate matrices: ... data with the third column=1.0. So essentially splitting the data by the values 0.0 or 1.0 in the third column. ... Save this answer. ... Show activity on this post. If you're using Numpy, first find the rows where the third column has your ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 25, 2017
๐ŸŒ
w3resource
w3resource.com โ€บ numpy โ€บ manipulation โ€บ hsplit.php
NumPy: numpy.hsplit() function - w3resource
April 24, 2026 - The numpy.hsplit() function is used to split an array into multiple sub-arrays horizontally (column-wise).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-hsplit-function-python
numpy.hsplit() function | Python - GeeksforGeeks
July 12, 2025 - The numpy.hsplit() function is used to split a NumPy array into multiple sub-arrays horizontally (column-wise). It is equivalent to using the numpy.split() function with axis=1. Regardless of the dimensionality of the input array, numpy.hsplit() ...
๐ŸŒ
PythonForBeginners.com
pythonforbeginners.com โ€บ home โ€บ split a numpy array in python
Split a Numpy Array in Python - PythonForBeginners.com
September 16, 2024 - The hsplit() function is used to split a 2-D numpy array horizontally i.e. along the columns. To split a 2-D array into sub-arrays having equal number of columns, you can pass the original array and number of required sub-arrays to the hsplit() function.
Find elsewhere
Top answer
1 of 2
3

One way of doing it using hstack:

import numpy as np
a = np.array([['burger flipper',  'part time',  '12-5.00'],
             ['spam flipper',    'full time',  '98-10.00']])
a = np.hstack((a[:,:2], map(lambda x: x.split('-'), a[:,2])))
print a

Output:

[['burger flipper' 'part time' '12' '5.00']
 ['spam flipper' 'full time' '98' '10.00']]

A bit of explanation:

  1. The function numpy.hstack allows you to horizontally stack multiple numpy arrays. For example,

    np.hstack((a[:,[0,1]], a[:,[2]]))
    

    produces the original array a with three columns. Note the use of brackets in a[:,[2]], [a:,2] will not work as it produces a single dimensional array (len(a[:,2].shape) equals 1).

  2. The map statement apply a function lambda x: x.split('-') to the problematic column (i.e. the 3rd column) of the array. Each call to the lambda function returns a list containing the separated job codes and wage, such as ['12', '5.00']. Thus, the map statement produces a list of list which looks like [['12', '5.00'], ['98', '10.00']]. This can be converted to a numpy array with 2 columns when being fed to hstack.

The code hstack first two columns of the original array with the list of list obtained via map, resulting in an array similar to what you want in the end.

2 of 2
1

map(lambda x: x.split('-'), a[:,2]) is now giving a list instead of two columns leading to the following error:

ValueError: all the input arrays must have same number of dimensions

Needed to change the previous code to:

import numpy as np
a = np.array([['burger flipper',  'part time',  '12-5.00'],
             ['spam flipper',    'full time',  '98-10.00']])
a_newcolumns = np.hstack((map(lambda x: x.split('-'), a[:, 2]))).reshape(a.shape[0], 2)
# need to reshape the list into a two column numpy array
a = np.hstack((a[:, :2], a_newcolumns))
print a

๐ŸŒ
Codecademy
codecademy.com โ€บ article โ€บ split-numpy-arrays
How to Split Arrays in NumPy? | Codecademy
We can use the np.hsplit() function to split a NumPy array along the columns or the horizontal axis.
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ split
NumPy split()
The `split()` function in NumPy is used to divide an array into multiple sub-arrays.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
NumPy: Split an array with np.split, np.vsplit, np.hsplit, etc. | note.nkmk.me
February 6, 2024 - Specifying axis=1 splits the array along the 1st axis, i.e., by columns in 2D arrays.
๐ŸŒ
Kanoki
kanoki.org โ€บ 2020 โ€บ 06 โ€บ 11 โ€บ how-to-split-numpy-arrays
How to split Numpy Arrays | kanoki
June 11, 2020 - hsplit(): Splits an array into multiple sub-arrays horizontally (column-wise).
๐ŸŒ
Towards AI
pub.towardsai.net โ€บ stacking-and-splitting-numpy-arrays-like-a-pro-part-2-d01fcefc742c
Stacking and Splitting NumPy Arrays Like a Pro: Part 2 | by Devansh Sheth | Towards AI
April 4, 2023 - What if we need to split the array into 2 parts in such a way that half of the columns in 1 part and other half into another part. For that hereโ€™s what we need to do. ... Even though the axis value defaults to 0, whenever we want to split row-wise, it is advisable to mention axis=0. ... To help us work with arrays having more than 1 dimension, NumPy also provides hsplit and vsplit functions.
๐ŸŒ
Reddit
reddit.com โ€บ r/askprogramming โ€บ split a 2d numpy array into 2 separate 2d arrays based on a column value
r/AskProgramming on Reddit: Split a 2d NumPy array into 2 separate 2d arrays based on a column value
October 19, 2020 -

So I have this 2d array that looks something like this

[[1,2,4],[1,4,4],[2,2,4],[2,5,9]]

The first column in this array can only ever be a 1 or a 2, I want to split this 2d array into 2 smaller 2d arrays, with all the arrays where the first column equals 1 are in and another where all the arrays whos column 1 has 2 in it. I am new to numpy and have seen some examples and documents online but i can't seem to get exactly what I want. Here is the current code I am trying to use

```

np.split(trainingData, np.where(trainingData[:, 0]== 1.)[0][1:])

```

I am basically trying to split the trainingData(which is my array) into 2 separate arrays, but when I run this I get more than 2 arrays. If someone could point me on the right path that would be great!

Thank you

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ splitting-arrays-in-numpy
Splitting Arrays in NumPy - GeeksforGeeks
December 23, 2025 - numpy.hsplit() performs horizontal splitting, which divides the array column-wise (axis=1).
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ numpy โ€บ numpy_split.htm
Numpy split() Function
Here in this example we show how to split a 2D array into 2 sub-arrays along the columns i.e. axis=1 โˆ’ ยท import numpy as np # Create a 2D array arr = np.arange(16).reshape(4, 4) print("Original 2D array:") print(arr) # Split the 2D array into 2 sub-arrays along columns result = np.split(arr, 2, axis=1) print("\nSplit 2D array into 2 sub-arrays along columns:") for i, sub_array in enumerate(result): print(f"Sub-array {i+1}:") print(sub_array) Original 2D array: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]] Split 2D array into 2 sub-arrays along columns: Sub-array 1: [[ 0 1] [ 4 5] [ 8 9] [12 13]] Sub-array 2: [[ 2 3] [ 6 7] [10 11] [14 15]] numpy_array_manipulation.htm ยท