Skip to playerSkip to main content
Welcome back to our NumPy series! In this tutorial, we dive into Slicing. Slicing allows you to extract specific portions of your data without copying the entire array, which is essential for working with large datasets in Machine Learning.

In this lesson, you will learn:
✅ The Core Rules: Understanding Start, Stop, and Step.
✅ 1D Slicing: How to grab ranges and reverse arrays.
✅ Negative Slicing: Accessing data from the end of an array.
✅ 2D Slicing: How to slice rows and columns simultaneously.
✅ Advanced Steps: Skipping elements and reversing data within matrices.

Liked the video? Don't forget to 👍Like, ↩️Share, and 🔔Subscribe!
!هل أعجبك الفيديو؟ لا تنسى الإعجاب، المشاركة، والاشتراك في القناة
@Intuidemy

🔗 Links & Resources:
GitHub (Source Code): https://github.com/rubada/Testing-in-Python-with-pytest
📺 Full Pandas Playlist:

#NumPy #Slicing #DataScience #PythonTutorial #MachineLearning #Coding #بايثون #نومباي #الذكاء_الاصطناعي #شرح_نومباي

Category

📚
Learning
Transcript
00:14Welcome back, and peace be upon you. Now we'll continue our discussion in Num Bye and see how we can do slicing.
00:22The rules we follow in NumPy to perform slicing are the same rules we followed in Python when performing slicing.
00:29Hey, if you've forgotten these rules, I've put the link to the slicing video here in this notebook.
00:37You can go to the Python course on the Anteo Demi channel and check out this video.
00:45And I will also put this link to this video in the description.
00:53You can go there, and there will also be a link to the GitHub where this notebook is located.
01:00Okay, let's see how we can do slicing. First, we need to start with slicing.
01:07But first, we need to see what the slicing rules are. We have two rules, we have start and stop, and we have start.
01:14Stop and step
01:15Okay, let's see how we can apply them now. Here, I have a single-dimensional array.
01:22I did several slicing operations, let me run a run and we'll check the result together. Now here I took
01:28My ari and I sliced ​​from zero to three, now the three will always be a stop, it will always be minus
01:35One will give me the result from zero to two, meaning the dragon, the six, and the eight. Here, I got the dragon, the six, and the eight.
01:44The same applies if I want to slice from Index 2 to Index 5; it will start at 8 and then proceed to 4.
01:52Then at nine it will stop at index 4 because 5 minus one will stop at index 4, so it will show me eight and four.
02:01and nine
02:01I can also use the two dots above each other to copy the file, just like it appears here.
02:07I can also use the stomp function; for example, I made a stomp here from one to seven, and then I make a stomp two.
02:15Okay, here I start with the zero shot, then the six, then the eight, then the four, then the nine, then the five, and it gives me six, four, and five.
02:26I can do the same thing now. As we know, a referral starts at the large index and ends at the small index.
02:36And the index for the dragon needs to be given what plus one. Now here I started from the six, which will be the one that
02:45I have one here, why? Because my index number is six here.
02:51Zero, one, two, three, four, five, six, so the two will be two plus one, so it will be three, so it will start with six, then five.
03:03Then what?
03:05Four, then three, so it will take one, five, nine, and four. If you also put seven here, it will give you the same result, no problem.
03:14But what
03:15We're putting it as a six, so whether it's a six or a seven, it'll give you the same result. Okay, now we'll also do the negative slicing.
03:26Negative slicing, like regular negative slicing
03:30Hey, for example, here I put several negative slicing options. Let's run a run and see what the result is. Now here I am
03:37I want to take from -7 to -4
03:40Okay, minus four minus one will give me minus five, so I want to start from minus seven to minus five, which is the minus.
03:47Seven, which is the dragon, and minus six, which is the six, and minus five, which is the eight.
03:53So, it gives me the same thing: the two, the six, and the eight. Here, I made a minus five, then a minus two, then a minus two, and one will stop at the minus.
04:02Three, so we start from minus five, which is eight.
04:05Then the minus 4, which is
04:08The four will stop at minus
04:103, which is nine
04:12It will give me 8, 4, and 9
04:14Just like he gave me here
04:16And we can also use
04:18The status is here, I want to start.
04:20From -7 to -1
04:22In STAP 2, will he take
04:24What is the first thing? What is the minus 7?
04:26Which is the dragon, will do
04:27Stab splits the six and takes
04:30The eight will split the four and take
04:32Nine and then
04:33He'll shoot the five, but he won't take anything.
04:36One, yes, why?
04:37Because we are minus 1
04:39Minus 1 will stop at minus
04:412 Valmence 2 done
04:44Stab, so he won't take it.
04:45What will I get?
04:47Dragon
04:50And the eight
04:51And the nine is good, that's for
04:54For the last thing, I can also
04:56Do a reverse here now
04:58I told Minus 1 of course
05:00In reverse, we start with the index.
05:02The large one is minus 1
05:04Minus 5 and degenerate
05:06Minus 1, hello, I'm here
05:08I took the minus 1, which is one.
05:10after
05:11Take the five and the nine
05:14He stopped at four because
05:15Minus 5 plus
05:181. Where will it stop at the minus point?
05:20Four, so he'll give me
05:22The Reverse
05:22okay
05:24I'm just now looking at De Ari
05:26First thing in 2D ARI
05:27To do slicing, we need
05:29What do we define?
05:30The raw material we want to work with
05:32slicing
05:32So, are you here?
05:34What did you do?
05:35Hi, I did
05:36Slicing kit
05:38High to Dimension
05:39Show
05:40Let's make it a run
05:41Hello, first thing I did was take this two-dimensional
05:43Show
05:44I took the first thing
05:46Raw Zero
05:47Which is this
05:48And I want to do slicing
05:49From one to three
05:51So, I prefer 72
05:52Stop at three minus two
05:55He'll stop at three.
05:56So he gives me seventy-two and three
05:58Same thing here
06:00I want to start making a copy
06:02For the second raw
06:04So here I put the index
06:06The second Raw followed
06:07Which is the one
06:08Then I put two dots on top of each other
06:10As you can see
06:11The Cuban gave me this ro
06:14We too
06:16We can do
06:17what
06:17We can do
06:18Step L
06:19Yes
06:20To De Ari
06:21For example, I am here
06:22I want to do
06:22Step L
06:24In the third Raw
06:26Which is
06:26The index followed it
06:28dragon
06:28What did you say?
06:30From zero
06:30Yes
06:31I put the index
06:32I followed this story
06:33And then
06:34Take
06:35Yes
06:36slicing
06:37On the Columns
06:38From zero to three
06:39And I put that
06:40Step Dragon
06:41He will take
06:42I have
06:42thirty-three
06:43Hayooqah
06:44Failure
06:44The eight
06:45And he will take
06:46The seven
06:47Because
06:48Three minus
06:48one
06:49He will give me
06:50dragon
06:50So he will stop
06:51when
06:51Monday
06:52Index
06:53dragon
06:53Which is
06:54The seven
06:54He will give me
06:55thirty-three
06:56and seven
06:56And what else?
06:57also
06:57I can
06:58Work
06:58Reverse
07:00Now I want to do
07:00Reverse
07:01For the fourth
07:03Which is
07:03Index
07:04I followed him
07:04three
07:05I put it here
07:06Index
07:06The fourth Ror followed
07:07And then
07:08I started
07:09In the index
07:09The large
07:10for the Landix
07:10The small
07:11And I put
07:12Mines
07:13one
07:13I loved him
07:14out of three
07:14Which is
07:16The nine
07:16And then
07:18Here
07:18Zero
07:18And then
07:19One
07:19why
07:20Because
07:21Zero
07:21plus
07:21one
07:22He will give me
07:23one
07:23So he will stop
07:24when
07:24Index
07:25one
07:25Hello, like this
07:27hopefully
07:27It should be clear
07:28Image
07:28Hello, here
07:29We will stop
07:29God willing
07:30In the next video
07:31We will continue
07:32in
07:33The
07:34Just now
07:35Ariz
07:35And then
07:36also
07:37We'll see
07:37how
07:37We can
07:38We work
07:38Slicing
07:39in
07:39The
07:40Thanks
07:41your
07:41See you
07:42In the video
07:43Next

Recommended