Sitemap
Mian

Mian

Self Motivated, Naive Programmer.

Indexing And NUMPY

3 min readJul 19, 2025

Hello Guys! Lets start Learning 😃.

print("Welcome to world of Numpy 😄")

Before we deep dive into Indexing, lets have a bonus!

Press enter or click to view image in full size
linespace func

Umm… you MIGHT be wondering is it creating spaces between line or what? 😆

NO!

Lemme Demonstrate the Output first.

Press enter or click to view image in full size

This method created an array, containing 10 integer values, starting from 30, and ending on 70, as per the requirement it can vary, and easily implemented 🤓.

Coming back to topic!

World of Numpy 🤓

Indexing

Press enter or click to view image in full size
arange func

Creating an array by calling a function named arange and mentioning as argument that we desire an array containing values starting from 0 till 11, Ofc excluding 11.

Press enter or click to view image in full size
Output for calling arange func

Lets implement Indexing!

Press enter or click to view image in full size
Did I really just learn indexing???

Yes! In first loc (Line of Code) we asked for the value that lies on 4th index inside the array named array, then in Second statement we asked for negative 2nd position.

Get Mian’s stories in your inbox

Join Medium for free to get updates from this writer.

But Before we get the result, lemme share with you, array could negatively indexed!

Yes you heard me correct 😃!

Negative sign indicates that you start reading from the trailing end of array.

Press enter or click to view image in full size
Waoh!

I am thinking what you are thinking! array[4] shouldn’t be the value 3, since its the 4th value in array!

Here is the twist, from left side of array, Indexing start from 0 and right side indexing start from -1.

LET’S DO SOMETHING MORE CRAZY!

Press enter or click to view image in full size
arange, reshape func

Lets create an array, and reshape it into Two Dimensions.

Press enter or click to view image in full size

This is how the 2D array looks like.

Press enter or click to view image in full size
Let’s do complicated indexing 🆒
Press enter or click to view image in full size
OOOOH 😮 !

The array is index row and column wise.

“ : 3” indicates that from very first row till 2nd row, the second portion of indexing, which begins after “ , ” is for columns, and its tells to index and get the values in array from 1st column till 2nd column.

You might have noticed that last values in indexing such as in row’s indexing values of 3rd rows were not part of rows, same as in for part column indexing value 3rd column was ignored, and this is expected behaviour not an error.

So these were foundations for understanding indexing using NUMPY. Don’t forget to explore at your own 🤓.

print("Yes I got it :D")

--

--

Mian
Mian

Written by Mian

Self Motivated, Naive Programmer.