#29 Python Tutorial for Beginners | Ways of Creating Arrays in Numpy
Вставка
- Опубліковано 21 лип 2018
- Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
Discord : / discord
In this lecture we are discussing about:
-- Ways of creating arrays in numpy:
we have 6 way of creating arrays in numpy
a)array()
b)linspace()
c)arange()
d)logspace()
e)zeros()
f)ones()
from numpy import *
arr =array([1,2,3,4,5])
print(arr)
print(arr.dtype) # int32
arr =array([1,2,3,4,5.0])
print(arr.dtype) # float
-- automatically it will convert the data type to float
arr =array([1,2,3,4,5],float)
print(arr.dtype) # float
-- we can also specify the data type of array
b) linspace()
-- it is used to create an array with equal interval between the elements
-- syntax: linspace(start,stop,num=50,endpoint=True,retstep=False,dtype=None)
arr=linspace(0,15,16) # here it break the range into 16 equal parts
-- by default it will take 50 parts
arr =linspace(0,15)
print(arr)
c) arange()
-- it is used to create an array with equal interval between the elements
-- syntax: arange(start,stop,step,dtype=None)
arr =arange(1,15,2)
print(arr)
-- it will create an array with start value 1 and end value 15 with step size 2
arr=arange(1,15,2.5)
d) logspace()
-- it is used to create an array with equal interval between the elements in log scale
-- syntax: logspace(start,stop,num=50,endpoint=True,base=10.0,dtype=None)
arr=logspace(1,40,5)
print(arr)
e) zeros()
-- it is used to create an array with all zeros
-- syntax: zeros(shape,dtype=float,order='C')
arr= zeros(5)
print(arr)
f) ones()
-- it is used to create an array with all ones
-- syntax: ones(shape,dtype=float,order='C')
arr=ones(5)
print(arr)
if i want work with int
arr=ones(4,int)
print(arr)
Github :- github.com/navinreddy20/Python-
Python for Beginners :- bit.ly/3JOLQhl
Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
Subscribe to our other channel:
Navin Reddy : ua-cam.com/channels/xmk.html...
Telusko Hindi :
ua-cam.com/channels/itz.html...
Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
www.telusko.com/contactus - Наука та технологія
I started learning programming through this Python playlist. It's the BEST!
Simple way to learn python, thanks for creating such excellent videos and keeping it free for everyone to learn .
thank you.....its fun learning with you....being cs student i was always afraid of coding...but the way you are teaching really creates interest and enjoy learning.....thankyou so much sir
Ur teaching is paranormal to others teaching sir I would like to appreciate ur videos sir tq....
nice one Mr == right sir. can't stop learning and running this
Thanks sir
You are supporting us .
may god bless u sir,,,,u r really doing a very good job!!
The best! Keep it going
choomeshwar.........you are too good. God bless you.
Clear and concise. it would be more useful if any real time examples are discussed
Hehe I am a total and complete n00b, you lost me at round lesson #21 to be honest, I am still going along to try and grasp the terminology etc. I think things will start coming together when I start doing practical examples. The material is incredible and I am loving it !
Sir Please don't hide yourself that is more understandable for me...thanks
Congrats sir, it reached 1M subscribers 😍😊
Thank you very much. You are a genius.
Difference beween linspace() and logspace():
Suppose you have a cake, and you ask linspace to cut it into 5 parts, linspace will cut it in five EQUAL parts, But if you ask logspace to cut the cake into 5 parts, it will cut the cake in five UNEQUAL parts. Everyone will get different sizes, just that it will cut in five parts that's it.
thank you bro...now i got it :D
Mr, Reddy.. Superb..
Hello Sir, i have a question, in Automation testing which scripting language i should choose java or python for getting job quickly and getting more calls.
Sir, can u clearly explain what exactly is logspace(). What is meant that the values are divided on the basis of a logscale
Yes
Same question.. its also important to us how can we use these in real world projects
It’s useful in numerical methods. Divided values means diving the range in particular parts.
Like if you divide 3 in 4 parts, 3/4 = 0.75
So, the values will be
0, 0.75, 1.50 and 2.25
No
@@_parm_ yes 😀
sir please explain the logspace() clearly , that is about how will the elements be divided any specific formula
same do u know now?
in linspace any 2 consecutive numbers in the array will have the difference, whereas in logspace any 2 consecutive numbers will have the same ratio. In this case the array starts at 1 * 10^1 and ends at 1 * 10^40. To get from one value in the array to the next you have to MULTIPLY by about 10^10, as opposed to linspace where to get from one number to the next you have to ADD the same value each time. That's my understanding at least.
i think its based on logarithms
Thank you Sir : )
Sir please explain clearly logspace once again so many has doubts on that
Hello sir thank you so much for this tutorial it's a great help, just one double in this video- can't understand logspace() , please help
Hi sir,
Can we find the series of sinx and the value of sine function at different values of x.
thank you so much sir.....
very helpful......
first comment........
today I just saw your meet up video, but it was late because I saw it on 11, I request you to tell about case studies,
i'am from science background.
Thanks bhaiya
Can you give us the PDF which will consist of all the concepts,methods to study and a better way to remember and study later
Pls consider my question sir pls
sir, but what is the use of this zeros and ones function in array...& when it can be use
Hello Navin, thank you for the good job that you continue to do. Just a quick one and not related to the above video, how comprehensive is this series? Does it cover all the basics (topics) that I would require to learn on Python? Thanks.
yeah it's good for learning python.
You increase my knowledge about python array to a higher level....You are really a genius
ע״י ה. בה
😊
בהה 😊
הנעהבעבי כביבי 😊
very helpful
thank you sir
we can also create an array though identity matrix like np.identity(3). It will create an identity matrix of 3x3.
This is the first video which is confusing for me earlier than this was the pass and continue confusion but Mr reddy himself clarified in the next video..Lets see.....
THANK YOUUUU
Awesome !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Awesome
could you explain zeros(),ones(),logspace(),linespace().
Hi Sir,
You are doing a great job.
I would like to give a feedback for this video. While importing module Numpy(or any other module) try to avoid using *, because it may have lots of functions with different names. In future, if we create a variable or method name with same name used in Numpy it may get conflict.
Import numpy as np
arr = np.array([1,2])
It could be the better way.
It's better that way but for learning purposes it might be overwelming to students to type each function on this video
Sir has discussed this things earlier. Please see the previous videos of this series.
Its good to know. Thanks.
Sir, this video is boring just because u weren't visible like in other videos, I highly appreciate the way you teach Python, I request you to make another video series on Java and do what you are doing with python, I mean to be physically present so that we can see you, I seriously think, this way we are able to grasp more of what you teach us!
thanks sir
sir please start a project so we can implement all things
sir please explain once again logspace()
Sir please explain the logspace() and linspace()
Nice video
Sir, while printing array created using logspace as print('%.2f' %arr[0]), You specified an index of one element. I want to print to the whole array here. Tried different ways as: print('%.2f' %arr), print('%.2f' %arr[]) But none works, getting different errors
good
hello sir
i installed numpy in the way you mentioned.I am using the default IDLE (python shell ).It still says numpy module doesn't exist when i try to run code.I have also went through sys.path() method to figure out where the IDLE is searching for numpy module and the module exists in that location.please help sir.thanks.
sir can please clarify the linespace method what are the parameters for statring and ending and for break points it is very confusing
Nice video , But this video creates lots of questions like where can we use these functions and whats the use of these functions.
Sir..I have 2doubts first is why it gives int34...and float64....and the another is logspace...I didn't understand this function..
Those who want Clarity on logspace()
---------------------------------------------------------------------------------------------------------
The values that are given as input are log(base10) values
so if input is 2 the actual value is 10^2=100(^ means power)
logspace() follows Geometric Progression
It uses log(base 10) values. In simple Terms
Eg : logspace(2,5,3)
here 2 means 10 raised 2 times which is 100 (Prior Knowledge on log is required here)
and 5 means 10 raised 5 times which is 100000
In Geometric Progression nth term is a*r^(n-1) (^ means power
here a value is 100
n is 3
last term (nth term)= a*r^(n-1)=100000
100*r^(3-1)=100000
100*r^2=100000
r^2=1000
r=10*sqrt(10)=31.622776601683796
so the 3 numbers are
100*(31.622776601683796)^0=100.0 ,
100*(31.622776601683796)^1=3162.2776601683795
100*(31.622776601683796)^2=100000.0
So The 3 numbers are 100.0,3162.2776601683795,100000.0
Like If You Got Clarity
Hello sir!
Ist of all thanks for sharing your knowledge and time with us
Second, i wish to work as data scientist and my question is : These 72 videos are sufficient for tackling the problems related to data and all? Or we need to subscribe other websites for more information?
Nice yeah
I have a doubt, while importing packages ie., what is the difference between "import numpy as np" and "from numpy import *". Is these two are same or different?
Good tutorial. I know Python but never tried numpy. I've a question: What's the use of numpy functions 'one' and 'zero'?
yeah what's that for
np.ones() function is used to create a matrix full of ones where as np.zeros() function is used to create a matrix full of zeroes. It can be used when you initialize the weights during the first iteration in TensorFlow and other statistic tasks.
Its very useful when u will learn Machine Learning with python. A lot of matrix calculation is involved there. Also yo will need matrix of ones and zeros for calculating things like eigen vectors, inverse of a matrix etc. I hope it cleared your doubt.
Sir please make same video of numpy using IDLE in IDLE it shows lots of error in same kind of code
sir how we can pass an multi dimensional array getting inputs from user
add two arrays using for loop:
from numpy import *
arr=array([1,2,3,4],int)
arr1=array([1,1,1,1],int)
for a in arr+arr1:
print(a)
Your code is incorrect. It does not add 2 arrays. If you want to add 2 arrays, the correct code would be: import numpy as np
arr = np.array([1, 2, 3, 4])
arr2 = np.array([1, 1, 1, 1])
a = arr + arr2
print(a)
Hey Navin, I am really enjoying the python lecture by u. I have query. May please tell me in lecture #29, u typed for the type of the array and is saying int32 or float 64, please clarify what is 32 and 64
It is size of int and float
Sir i have a question... What if it contain float,int,str ?? Then in what it will be converted ?
Sir,
in the output there is float64 in the starting of the lecture. what is 64?
sir, can we take user input to create an array when we import numpy ???
Can we use these functions for creating multi dimensional arrays
addition of array is
from numpy import *
arr1=array([1,2,3,4,5])
arr2=array([6,7,18,9,2])
for i in range(5):
arr3 = arr1+arr2
print(arr3)
You should put a underscore instead of space to assign a variable name. Like this
arr_1
arr_2
sir ur best but this time i had a little trouble in understanding logspace
if someone can explain it too me dont fell shy to reply
It is just the four parts from 1 to 40.
Eg (1.09800,2.3454000,7.0987700,37.)
Hi Sir,
but where we can use this different arrays
sir, for what purpose we need zeroes and ones, I didn't understand could you pls explain.
I have an array of order 8*412 I want to subtract every second row from every first row in the whole array and get it stored in a new array.. Can you suggest me something???
2:10 what is int"32"? and is logspace related to logarithms?
please help, i am trying to create the array and the program runs well initially and take the few inputs too but suddenly the program shows error in the middle, here is my program :
from numpy import *
arr=array([ ])
vals=int(input("Enter the number of slots :"))
for i in range(vals):
vali=int(input("Enter the value you want to store :"))
arr.append(vali)
print(arr)
arr .append(i)
What is the use of zeros() and ones() function?
Really amazing, if someone does not understand programming concepts from your videos then programming is not a way for that person...was joking...still anyone can learn to program....I love your all videos.
hey can I get notes of all python videos available on this channel
sir, can u please explain logsapace() clearly and when we use dtype function it shows int 32 and float 64 but what is the meaning of that numbers?
float 64 means 64 is a bit size of float
1 bit = 8 bytes
Hi, I have newly joined ur classes about python and downloaded the latest version of it, but it's not working, whenever I m feeding input its says error. I cant also run the command prompt, IDLE, and the NumPy installation. what to do?
Is arange same as range .in that also last value excluded??
what if we don't specify the 3rd parameter in arange()....for example arange(10,2)??
Sir, how can we create an array dynamically using numpy library?
Sir , this arange doing same as range
whats is specific use of this arange ??
for ex: arange(1,15,2) output of this is same as that of range(1,15,2)
how to create 3 *3 matrix with all zeros elements using function zeros(),how to create multi dimesional arrays by taking values from user sir?
Sir, how to take user input using numpy array ?
Sir if we are getting all the facilities in numpy package itself then what is the purpose of array package? Why it is there in python? As u said that we can also create a single D array in numpy then why to use array package.
sir... mine is showing undefined array...what to do so?
i am getting the following error whlie installing numpy -
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy-1.18.2.dist-info'
Consider using the `--user` option or check the permissions.
what should i do?
Hlo alienbro at first what is the number after the int and float that is 32 and 64 what are that numbers
What's the use of Zeroes and ones array ?
Hi Sir, Your teaching skills are excellent. I have a doubt, can I use python instead of javascript?
no
python is used for back end programming whereas javascript is for front end
sir what is the use of linspace and logspace
Sir I am faceing problem with pycharm .....configuration problem that no interpreter found I see many videos but I can't solve ... please suggest me any best video for pycharm settings. .please sir.. Thank you in advance...!
Hi sir
Int and float is there
But how to came int32 and float64
t-3.19 mins
I don't know the reason why 15 is not printed in the output region.
Please explain???
Y to came in output like int32 amd float64.
Iam not understand sir
why i am not able to import numpy in pycharm?i can access it in jupyter notebook and idle also
why linspace() and arange() not working in jupyter notebook
can any one plz help me that why it is givinf int32 but not only int and similarly float64
sir my im facing problem with numpy installation in pycharm my idle is has numpy bt my pycharm is showing error for installing of numpy
please help me out with it ........my idle is of 32 bits where as pycharm is of 64 and ide is using lattest version of python whereas pycharm is running on 3.7.., so please try to help me out with this and fix this
Can u mention how and where we can implement these?
I am getting below error. Why?
NameError Traceback (most recent call last)
in
1 import numpy as np
----> 2 arr = array ([1,2,3,4,5])
3 print(arr.dtype)
NameError: name 'array' is not defined
multidimensional array program???
Sir, Where we can use logspace , can u give us some Idea ?
😊
the linspace and others are similar to the ones in MATLAB