Array in numpy

Python Programming Introduction to numpy
7 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.94
List Price:  €92.78
You save:  €27.83
£55.57
List Price:  £79.40
You save:  £23.82
CA$95.27
List Price:  CA$136.11
You save:  CA$40.83
A$107.88
List Price:  A$154.13
You save:  A$46.24
S$94.55
List Price:  S$135.08
You save:  S$40.52
HK$547.57
List Price:  HK$782.28
You save:  HK$234.71
CHF 63.42
List Price:  CHF 90.61
You save:  CHF 27.18
NOK kr759.63
List Price:  NOK kr1,085.23
You save:  NOK kr325.60
DKK kr484.38
List Price:  DKK kr692.01
You save:  DKK kr207.62
NZ$117.46
List Price:  NZ$167.80
You save:  NZ$50.34
د.إ257.02
List Price:  د.إ367.19
You save:  د.إ110.16
৳7,682.93
List Price:  ৳10,976.08
You save:  ৳3,293.15
₹5,837.41
List Price:  ₹8,339.52
You save:  ₹2,502.10
RM331.26
List Price:  RM473.25
You save:  RM141.99
₦99,285.71
List Price:  ₦141,842.81
You save:  ₦42,557.10
₨19,466.20
List Price:  ₨27,810.04
You save:  ₨8,343.84
฿2,553.28
List Price:  ฿3,647.70
You save:  ฿1,094.41
₺2,262.39
List Price:  ₺3,232.12
You save:  ₺969.73
B$349.43
List Price:  B$499.21
You save:  B$149.77
R1,335.92
List Price:  R1,908.54
You save:  R572.62
Лв126.45
List Price:  Лв180.65
You save:  Лв54.20
₩94,634.34
List Price:  ₩135,197.71
You save:  ₩40,563.37
₪258.03
List Price:  ₪368.63
You save:  ₪110.60
₱3,943.57
List Price:  ₱5,633.91
You save:  ₱1,690.34
¥10,600.67
List Price:  ¥15,144.47
You save:  ¥4,543.79
MX$1,161.53
List Price:  MX$1,659.40
You save:  MX$497.87
QR255
List Price:  QR364.31
You save:  QR109.30
P959.59
List Price:  P1,370.91
You save:  P411.31
KSh9,203.68
List Price:  KSh13,148.68
You save:  KSh3,945
E£3,310.52
List Price:  E£4,729.52
You save:  E£1,419
ብር3,976.27
List Price:  ብር5,680.63
You save:  ብር1,704.36
Kz58,526.41
List Price:  Kz83,612.74
You save:  Kz25,086.33
CLP$68,581.80
List Price:  CLP$97,978.20
You save:  CLP$29,396.40
CN¥506.04
List Price:  CN¥722.95
You save:  CN¥216.90
RD$4,144.87
List Price:  RD$5,921.50
You save:  RD$1,776.62
DA9,443.17
List Price:  DA13,490.83
You save:  DA4,047.65
FJ$158.28
List Price:  FJ$226.12
You save:  FJ$67.84
Q545.87
List Price:  Q779.86
You save:  Q233.98
GY$14,645.83
List Price:  GY$20,923.51
You save:  GY$6,277.68
ISK kr9,762.20
List Price:  ISK kr13,946.60
You save:  ISK kr4,184.40
DH709.20
List Price:  DH1,013.19
You save:  DH303.99
L1,234.28
List Price:  L1,763.34
You save:  L529.05
ден3,991.30
List Price:  ден5,702.11
You save:  ден1,710.80
MOP$564.10
List Price:  MOP$805.89
You save:  MOP$241.79
N$1,325.35
List Price:  N$1,893.44
You save:  N$568.09
C$2,576.69
List Price:  C$3,681.15
You save:  C$1,104.45
रु9,334.54
List Price:  रु13,335.63
You save:  रु4,001.09
S/259.58
List Price:  S/370.84
You save:  S/111.26
K267.89
List Price:  K382.72
You save:  K114.82
SAR262.49
List Price:  SAR375
You save:  SAR112.51
ZK1,765.85
List Price:  ZK2,522.76
You save:  ZK756.90
L322.98
List Price:  L461.43
You save:  L138.44
Kč1,645.46
List Price:  Kč2,350.75
You save:  Kč705.29
Ft25,709.21
List Price:  Ft36,729.02
You save:  Ft11,019.81
SEK kr749.87
List Price:  SEK kr1,071.30
You save:  SEK kr321.42
ARS$60,034.20
List Price:  ARS$85,766.82
You save:  ARS$25,732.62
Bs483.70
List Price:  Bs691.04
You save:  Bs207.33
COP$271,296.95
List Price:  COP$387,583.68
You save:  COP$116,286.73
₡35,581.11
List Price:  ₡50,832.34
You save:  ₡15,251.22
L1,728.07
List Price:  L2,468.78
You save:  L740.71
₲516,441.87
List Price:  ₲737,805.73
You save:  ₲221,363.85
$U2,647.22
List Price:  $U3,781.90
You save:  $U1,134.68
zł280.50
List Price:  zł400.73
You save:  zł120.23
Already have an account? Log In

Transcript

So today we'll be starting with the second lesson on NumPy library. So let us first import the library. So import NumPy as NP. Now, let's create a list with a square bracket. So I'm giving the nice name as least one, then I'm creating a list called suppose, one comma two comma three comma four, comma five. So these are the elements of my list, so run it, and then we'll create an array called era underscore one.

So now I'll be creating an array which will be equal to NP dot arrey. And within this first bracket, I'll write the lists that are created in our previous state. So list and this whole one. Now basically, what we're doing here is We are creating the simplest structure we can find. So now just run it through now check the type of what we have created. So type era underscore one.

So it says that it is created num p.nd. And I've already described you that was en de la what it is. So it is important to know that besides site we have other detailed function to properly understand what D type is let's just write a RR underscore one dot d date and run. So what printed is printed in 32. So you can see that this function allows us to verify that type given within our array. So what value you have written within this adding is actually denoting here that These are integers, so it has printed in 32.

Now let us just add a value called here, I'll add a value called 6.1. Now as we know that 6.1 is a float. So here, let's rerun this program. So Run, run this and run this and see what it printed it printed float 64. Now, what it has done is it has changed automatically all the data into float 64. Now if I add a string, suppose if I change this for into a string, let's just change this phone into a string and let's rerun this whole program.

So what it printed it printed you 11 which is an Unicode and it indicates that this is a character and string. Now let's analyze the order function which will be the size function. So let's just write Era underscore one dot size. And so what it printed is it printed how many values are how many elements are there within your area. Now here I haven't printed the error so if you want to print the error, just write it here and it will print so it has printed the six elements of the Edit like it is printed over here. Now that's why six is returned, while I run era underscore one dot size with the size function.

Now let's compare it with the shape function that we have used in a previous lesson. So let's run a RR underscore one dot shape. Now see it has printed six with a comma. Can you tell me what is the difference between size and shape because if we had more lists within this list, the program would have also show us the number of lines in the list that is shape function would have written that How many lists are present within a particular list within a single list. So, the difference is with size, we can see the number of elements on which shape, we can see the dimension, which is more useful. And remember, she is used more than size.

In fact, now we can use this shape function in a different way also. So the different ways in the dot shape and within this bracket, give the elleny and run it see it has printed the same result. So these are the two way we can use this shape function. Now let's analyze another function which is called the ending function which makes us directly see the dimension. So how we can use it era underscore one.nd and run it so it has printed one because here my error is one dimensional. Now it is two dimensional printed over here.

Now let's just create hit one list that is our list within a list. And let's just ship these functions one more. So here I'll create it, we know how to create it. I've done it in a previous lesson. So yeah, right. This is one list.

And the second list is character list. Let us create no running now check the shape. First anything dot shape, within the bracket, write the adding. Now here I've created the array directly I haven't saved is added to any particular I haven't given any particular name. So first, I need to give a name so unright airy underscore two, which is equal to this. So run this program first.

And then here you can call this or you can print this error. So it is printed the same thing. Now you can write the angry name over here. So era underscore two. Now if you run this, what you get, you get two comma three Now what this value refers to humans to listen Are there and treatments number of elements in each list. Now, if you increase the element, suppose here you write two and here again you write a particular element like now run this and again run this program, see the value changed, it is now two comma four.

So four is the number of elements within each list and the first number refers to the number of lists present within a single list. So if you want to create one more list here, now just write it in this way. So two comma eight comma nine, comma seven, no one sees now three comma four. So three is within a list and each list contains four elements. So now it is giving the dimension now check the this ending function with this Eric loop, so I'm just write a RR underscore two.nd. Now see what it is printed is printed.

Now, so it is a two dimensional array. So it is going to now, let us use one more function or three function to fill the array with values we want. So, how to use it? So, era underscore one now right Godfrey now within this bracket give a number that you want to provide. So, I am given this one so run it now see the result it has printed So, it has printed five and it has replaced all the values of a r1 that is everyone what are the values of everyone yes this post so, it has six values so, it has replaced on the values by the value fights So, we have come to the end of our lesson. So, here we have learned a few more functions of NumPy library and how can use it and we learn something more In our next lesson till then keep practicing seeing the next video.

Thank you

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.