AI engineering glossary · NumPy pandas visualization

What is np.newaxis?

np.newaxis (also called None indexing): An alias for None that, placed inside an index, inserts a new axis of length 1 into an array. This turns a flat array into a column or row and is the usual way to make shapes line up for broadcasting.

Level: intermediateTopic: NumPy pandas visualization

np.newaxis: an example

With x of shape (5,), x[:, np.newaxis] has shape (5, 1), so it can be combined with a shape (3,) array to give a (5, 3) result.

Related terms

More NumPy pandas visualization terms

Where you learn it

np.newaxis is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.