Numpy Shapes and Slices in Overview

Daniel Deutsch
Feb 20 · 3 min read
Photo by Hunter Harritt —

As data scientist / machine learning engineer it is necessary to deal with many Numpy arrays. Sometimes in the process, I lose an overview of all shaping and indexing syntax, so here is an overview.

Shapes and Dimensions

Shape 1 Dim

Shape 2 Dim

Shape 3 Dim



Arrange with slice:


Index with slice

Indexing 2 dim array

Indexing 3 dim array

The same principles for more dimensional arrays:

Indexing 4 dim array

Here in form of a Gist

A really good article with nice visualizations can be found here:


Daniel is an entrepreneur, software developer, and lawyer. His knowledge and interests evolve around business law and programming machine learning applications. To the core, he considers himself a problem solver of complex environments, which is reflected in his various projects. Don’t hesitate to get in touch if you have ideas, projects or problems.

Connect on:

Createdd Notes

Articles on Programming and Law

Daniel Deutsch

Written by

Business Law and Machine Learning. Pushing the limits to make the world a better place. Open for Projects of any kind.

Createdd Notes

Articles on Programming and Law

More From Medium

More from Daniel Deutsch

Also tagged Arrays

Also tagged Numpy Array

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade