Skip to content

docs: add column_stack to ndarray-for-numpy-users guide - #1618

Open
chiliec wants to merge 1 commit into
rust-ndarray:masterfrom
chiliec:docs/column-stack-numpy-users
Open

docs: add column_stack to ndarray-for-numpy-users guide#1618
chiliec wants to merge 1 commit into
rust-ndarray:masterfrom
chiliec:docs/column-stack-numpy-users

Conversation

@chiliec

@chiliec chiliec commented Sep 10, 2026

Copy link
Copy Markdown

Closes #650.

What

Adds a np.column_stack row to the "Array manipulation" table in the
ndarray_for_numpy_users guide, next to the existing concatenate/stack rows.

Why

column_stack is a common NumPy call and the guide had no direct entry for it,
so users had to work out the stack(Axis(1), …) idiom themselves (see issue).

Idiom

For 1-D arrays, np.column_stack((a, b)) builds a 2-D array with a and b
as columns — that's exactly stack(Axis(1), &[a.view(), b.view()]) (or the
stack![Axis(1), a, b] macro), matching the table's existing style.

Verification

Compiled both forms against this checkout:

let a = array![1., 2., 3.];
let b = array![4., 5., 6.];
stack(Axis(1), &[a.view(), b.view()]).unwrap()  // => [[1,4],[2,5],[3,6]]
stack![Axis(1), a, b]                            // => [[1,4],[2,5],[3,6]]

Both produce the numpy column_stack result. Docs build clean:

  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps — exit 0 (intra-doc links resolve)
  • cargo test --doc ndarray_for_numpy_users — ok

Happy to adjust the wording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an example for an equivalent of numpy's column_stack function in ndarray_for_numpy_users

1 participant