Here are the operations that you can do with Arrays. Just install Numpy in your machine to work with python arrays.
Check out how to download NUMPY, and install using the “import NumPy as np” command. After the installation, check Numpy installed correctly.
With Numpy I did a small experiment. You may aware that ‘NumPy’ is a python package used in analytics.
8 Python Array Operations
- Create an array
- Mathematical operations like-add, Subtract, Multiply, and Division you can do on arrays
- You can join two arrays
- You can Copy one array to other
- Read and Write of Array data onto Files
- You can create Structured Arrays
- Vectorization of array elements also possible
- Slicing an Array
1. Declare
Using Python array function, now I am defining an array
array()
>>>a = np.array([1,2,3,5])
>>>a
>>>type(a)
The type() function tells you the type of an array.

How to get Dimension of an Array in Python. Explained with the best example.

Also You May Like : Top Libraries You Need for Data Analytics
2. Addition, Subtraction, Multiply & Division
You can do Addition, Subtraction, Multiply, Division on arrays

You can also get the index of each element. Index starts with ‘0’. So, to get an element of the second index is ‘3’.

3. JOIN Two Arrays
You can join arrays either horizontal stacking or vertical stacking. Use vstack() or hstack().

4. COPY Array to Array
You can copy data of one array to another. Explained the best example.

5. COPY Array to File
You can write data of an array into a file. There are two functions. One is save() and the other one is load().
The file which is saved will have the extension’.npy’

6. Structured Array
Creating more complex arrays is called “structured arrays”. In an array, you can give of value with any data type.

7. Array Vectorization
Vectorization is the absence of an explicit loop during the development of the code. These loops actually cannot be omitted, but are implemented internally and then are replaced by other constructs in the code.
The application of vectorization leads to a more concise and readable code, and you can say that it will appear more “Pythonic” in its appearance.
In fact, thanks to the vectorization, many operations take on a more mathematical expression. For example, NumPy allows you to express the multiplication of two arrays as shown:
a * b
Or even two matrices:
A * B
8. Slicing an Array
I want to tell you the best example. Suppose you created an array of 4×4. You can split the same array as 2×2. This is called change of array dimension.

Related Posts

Don’t Forget to Share This Post!
You must be logged in to post a comment.