Change language

Numpy Hands on | Python

Numpy Hands on | Python

Lets start with numpy hands-on and this  is a quick introduction to numpy so that you know what exactly is numpy and how does it  work so we will see more examples of numpy later on but it is just a quick introduction to numpy  so im having a new notebook here in the anaconda jupiter lab environment and we are having numpy  so i will just import numpy as import numpy as np this is a standard convention that we follow  we give np as a name and it is very easy to use a common vocabulary with your peers and  everyone understand and be stand for numpy so thats why im using np yeah and once we do  this thing like and numpy as np we imported that then we can also see which version of numpy  we are using and this is helpful when you are lets say raising a request may be on stack  overflow or you are asking a question or you are having some issue so then you can actually  get to know like which version of numpy i am having right now and if i am having any  issue then i want to ask the question on the forum on the stack overflow then i can specify  this is the particular version of numpy im using and im facing this particular issue so this  this is helpful like version related information is helpful not just for asking questions  but also ensuring that the compatibility is there with specific libraries a lot of things  are taken care by anaconda but again if you have this information then it will be helpful for you  to actually um ensure that the other library that you are using is compatible with this particular  version of numpy if it is not covered by anapanda so i am saying np dot and after that you  will you will see like what exactly is available under that so we have i i just did np dot tab and  after that i have so many methods so these methods related to um like metrics and then methods  related to bitwise operator and then lot of other methods just have a look um lets start using some  of these methods then it will make much more sense but i just wanted to show you the capabilities  like how do we get to know which all methods are there and also there is another one which is  like we have uh np question mark so if you do np question mark then you will see the documentation  for this module and then here you will see some examples also that you can try out at your end  right so help is also there you can see and you can explore this more so lets see how do we  define a numpy array so i am defining a equals to np dot array and after that when we are defining  it we can also see what is there in a lets say i am defining like this and i am saying a so this  is my numpy array and i can even see the type of a so type of a is not python vanilla python type it  is numpy type and this is and im saying i have lets say some float value and im saying 3 and  im running this and when i execute b then you can see it has converted other elements also to  float so it is implicit type casting which is happening because one element was float so other  elements are also treated as float because it is homogeneous error type it is not list so list  can have heterogeneous types but here it is all homogeneous type i am defining a matrix let us say  matrix is equal to np dot array and i am defining a 2d array so here this is one and then another  one so i am just defining this 2d array here and i am specifying some of the elements so lets  say i define this and another one like this and this one is 6 7 maybe 8. so this is my matrix and  this matrix looks like this now this matrix i can always do lot of operations on this matrix so  these operations there are so many operations so i will just quickly choose transpose  operation and i will run it so when i transpose then it is able to give me transpose of the  matrix so quickly so easily without actually writing any loops i am able to achieve it i can  also define another matrix let us say i define this and i am saying np dot random im defining  this matrix through some random numbers and data and i am saying i need 3 by 3 matrix and it im  scaling it by 10 and i got another matrix and im just running it and i got these values  these are random numbers generated uh 3x3 dimensions and i can take dot product of these two  so i can simply say np dot and i i have one matrix and i have another matrix so i am running it and  i am able to achieve the dot product of these two matrices without writing any loops right and i  can also do another thing like this is another convenient way of writing the same thing so  this and this both are giving me same results so this is like a newer syntax compared to this one  so i hope you got an idea how to work with numpy

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically