Python NumPy Tutorial for Absolute Beginners - #3 Array Attributes (fast pace)

preview_player
Показать описание
Learn programming in NumPy, a Python Library, 100 seconds at a time in this video for beginners. This is video number 3: NumPy Array Attributes

I know im going fast in this video, please use timestamps below to navigate the video.
Timestamps:
00:00 - intro
00:07 - array shape
00:16 - shape in a function
00:30 - ndim and size
00:40 - accessing values
00:53 - changing value inside array
00:58 - accessing and changing values in 2 dimensional array

—————————————————————
NumPy Array Attributes
—————————————————————
Let’s take a look at some attributes of arrays

Numpy has built in function check certain attributes of arrays
The shape function shows what how many rows and columns an array has
In this example the array has two rows and 4 columns

The shape can also be defined inside a function to create an array
Lets take the ones function we covered in the previous video
We can define the shape inside the function in the same way we can define the data type

The function .ndim show how many dimension the array has

And the size function shows the amount of values inside the whole array

To acces an individual value inside an array pass the index number inside between square brackets like this.
Notice that this is the same way as accessing a value in a Python List.
print(data[0])

Changing the value of an element is also the same way as in a Python list, like this
data[0] = 2

To access the values in a two dimensional array you need to pass an index number for first the row and then the column.
This is two dimensional array with two rows and 4 columns.
Remember Python starts counting at 0. So the index number for the the first row is 0.
For the second row the index number is 1
The same goes for the columns. The index number of the first column is 0, the second one, etc.
Here we access the value on the first row and the third column
print(data2[0,2])
To change this value to 3 we can use the following code
data2[0,2] = 2020202 ————
 
————————————————————————

🦁 Who are you?
My name is Raza. I am 30. I am an IT - manager right now, but I’ve been an accountant for the majority of my career.
I’m in love with #Python :)

You can find me here:
—————————————————————————————

Goals for 2021
Training Python hours: 45/1000
Python/Django Projects: 1/30
Subscribers: 1753/10,000

—————————————————————————————-
#100SecondsOfCode
#pythonforbeginners #programming
Рекомендации по теме