'Retrieval of one column of an array outputs a shape of (1, 2) instead of (2,1). What am I missing? [duplicate]
I have an array z = np.array([[1,2,3], [4,5,6]]) which has the shape (2, 3).
Within one column there is one x and one y value. I want to retrieve the values of one column print(z[:, 2]. However, instead of outputting a (2,1) shape, I get a (1,2) shape.
The output I got:
[3 6]
The output I expect:
[[3]
[6]]
The thing is, I want to add z[:, 2] to another variable of the shape (2,1). What am I missing? And how can I achieve my goal? Thanks a lot in advance.
Solution 1:[1]
You need to slice with a 2D selector:
z[:, [2]]
output:
array([[3],
[6]])
Solution 2:[2]
Fix:
Quit Xcode.
run below command in terminal.
echo "settings set plugin.process.gdb-remote.packet-timeout 300" > .lldbinit
Restart system & restart xcode
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mozway |
| Solution 2 | Sangy05 |
