import numpy as np

Numpy is the fundamental package for scientific computing with python.It contains powerful N-dimensional array object,sophisticated (broadcasting) functions,useful linear algebra, Fourier transform and random number capacities.It can also be used as an efficient multi-dimensional container of genetic data.This allows Numpy seamlessly and speedily integrate with a wide variety of data sets.

Text can be converted in various ways into numerical representations,some clips can be thought of as one dimensional array of intensity versus time.No matter what the data are,the first step in making them analyzable will be to transform them into array of numbers.For this reason, efficient storage and manipulation of numerical arrays is absolutely fundamental to the process of doing Data science.
Let take a look at one of the specialized tool that python has for handling such Numerical array which is The Numpy package (numerical python). Numpy arrays are like python built-in list type,but Numpy arrays provides much more efficient storage and data operations as the array grows large in size. We will cover some common operation,but first let's import Numpy.

import numpy as np
1) .arange()
 The .arange() function in python which is identical to 'range',give the output the set of numbers with reference to the step value indicated.
a=np.arange(1,10,2)
print(a)
out:[1 3 5 7 9]
2) .linspace()
 .linspace()operation evenly-spaced number within the range
hello=np.linspace(1,10,4)
print (hello)
out:[ 1. 4. 7. 10.]
3) .concatenate()
 concatenation or joining of two arrays in Numpy, is primarily accomplished through the routines concatenate,np.vstack takes a tuple or list of array as its first argument
x=np.array([1,2,3])
y=np.array([3,2,1])
np.concatenate([x,y])
out:array([1, 2, 3, 3, 2, 1])

4) .split()
The opposite of concatenation is splitting, which is implemented by the function np.split()
x=[1,2,3,99,99,3,2,1] x1,x2,x3=np.split(x,[3,5]) print(x1,x2,x3)
out:[1 2 3] [99 99] [3 2 1]
5) .reshape()
Reshaping array is a useful type of operation,the most flexible way of doing this is with the reshape() method. for example, if you want to put the number 1 through 9 in a 3 x 3 grid, you can do so by;
grid=np.arange(1,10).reshape((3,3))
print(grid)
[[1 2 3] [4 5 6] [7 8 9]]

6) .var()
 It returns the variance of the array elements along the specified axis.A measure of the spread of a distribution
a=np.array([[12,17],[13,14]])
value=np.var(a)
print(value)
out:3.5
7) .std()

a=np.array([[1,2],[3,4]])
value=np.std(a)
print(value)
out:1.118033988749895

There are more operations available in the Numpy package, but hope this blog post has given you an understanding about the Numerical python (Numpy),each code were run using Jupyter notebook.
RESOURCES:
Python Data Science by Jake VanderPlas

Thanks for reading through, please share your thought at the comment section and share if this post has been helpful.

Comments

  1. Good post! You can share it on medium.com as most technical readers and writers use it compared to blogspot . Well done!

    ReplyDelete
  2. I can really relate to this now. Its fun having gone through ĺearniqng a subject and understanding it when it s brought to such a great platform as "analysisinbitwithmelody"
    But this needs a wider reach.. ☺❤👍✌

    ReplyDelete

Post a Comment

Popular posts from this blog

Data: The New Oil

How to push your Jupyter notebook file from your local computer to Github