Skip to content

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

Merged
akern40 merged 1 commit into
rust-ndarray:masterfrom
chiliec:docs/column-stack-numpy-users
Oct 18, 2026
Merged

akern40 merged 1 commit into
rust-ndarray:masterfrom
chiliec:docs/column-stack-numpy-users

Conversation

@chiliec

@chiliec chiliec commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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.

@akern40
akern40 force-pushed the docs/column-stack-numpy-users branch from 474d19b to e17da3c Compare October 18, 2026 23:06
@akern40
akern40 merged commit 98957ca into rust-ndarray:master Oct 18, 2026
15 checks passed
@akern40

akern40 commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

@chiliec thank you for your contribution! Sorry for the delay; life had gotten a little busy, I'm trying to get back to the repo now

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

2 participants