Numpy Basics-My experience
Published: 2022-12-25 16:21:45

Numpy is a python library.
One of the most famous ones. Numpy stands for numerical python.
It is used for working with arrays. 
Array is like python list but it is more than just list. It is faster than list and also consumes less storage. It's like in math what we call 'matrix'. All that we do with matrices in math we can do with array in numpy in programming rather, using the same theme, numpy has huge amount of other features. It allows us to use data and visualise in a matrix themed way and it is really powerful.

I mentioned previously in {% embed https://www.linkedin.com/posts/md-musfikur-rahman-sifar-96ab09258_mlabrwithabrmitul-diveabrwithabrsifar-activity-7006998327942615040-8W6w?utm_source=share&utm_medium=member_desktop %}what are the basic terms and subtopics of basic python. We always need to keep in mind about those after all we are using python. Here we also have those common topics like slicing, operating etc. So we can easily relate them. So, following that here is the list of the basic topics-

- Creating arrays

- Array attributes and methods

- Slicing

- Operating

## Creating Arrays
we can create arrays two ways-

- Conversion from other python structures

- Intrinsic numpy creation objects

###Conversion from other python structures(From lists, tuple, etc)
Firstly, we need to import numpy. We can use numpy as np.
`import numpy as np`
We use `array()`to create array. The syntax is

```
import numpy as np
arr=np.array()
```
array() takes arguements where we can give input.

![arrays creating](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr95uppbakvdmdab3rfc.png)
![print](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iz35k5qf3vh4sy187a3c.png)
We can create multi-dimensional arrays by putting'[]'
and check the dimension by putting `.ndim`
######Trick: Dimension=Number of '[' from one side

![array dim](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p1dqmy4bvev0ozcwg75.png)

![print](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec7hsusmxurebd73rwa4.png)
We can take multiple arguments

![mul arg](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cr2eneo7pji2nth3ze7b.png)
There's also different datatypes..I don't know much about them yet😅

###Intrinsic numpy creation objects(arange,zeros,ones etc.)
`.arange(start_inclusive,end_exclusive,step)`-creates array within the range of number serially
`.zeros((row number,column number))`-returns array only with 0
`.ones((row number,column number))`-returns array only with 1
`.identity((row-column number))`-return identity matrix
![methods](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dqif85onemfmvwoy517.png)
![print](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/znbrjeqj4cxvx3wq68w3.png)
We can also create random numbers:
`.random.rand((row_number,column_number))`-creates random number in [0,1) range
`.random.randn((row_number,column_number))`-Return a sample (or samples) from the "standard normal" distribution. Unlike rand which is uniform
`.random.randint((start_inclusive,end_inclusive,total numbers))`-random numbers within a range

##Array attributes and methods
`.max()`-returns the maximum entry
`.min()`-returns the minimum entry
`.argmax()`-returns the index of max value
`.argmin()`-returns the index of min value
![arrtributes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45at20kshnu71i9qhkcq.png)
We can also see the shape of the array and also reshape it 
**Note:**For reshape it must be total entries=new_row*new_column 
`.shape`-to know the shape of the matrix
`.reshape`-to reshape
![attr](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2te6f2d03vm6ygf8tsp.png)
##Slicing
**Syntax:**
arrayname[rowstart_inclusive:rowend_exclusive,columnstart_inclusive:columnend_exclusive]
**Note:**careful about inclusive and exclusive
![Slicing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7bnx6hfprx0np1viin4.png)
##Operating
It is like regular operation in math
![Operation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oci2myleioyi69livle4.png)

There are also other methods and attributes like-
![extra](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nve27xz7xrxtzls803mk.png)
More we explore more we know about these things and play with them
##Experience:
Numpy gets really easy to understand when you relate it with matrix. Know your methods and attributes. But need to be careful about syntax. It was the biggest challenge for me.

There are many other features. It will get even amazing..Still at the beginning...let's continue learning...let's dive together.