Path: blob/master/Data Analysis using Python/NUMpy.ipynb
3074 views
Numpy:Introduction
NumPy is a Open Source Python package. It stands for Numerical Python. It is a library consisting of multidimensional array objects and a collection of routines for processing of array.
NumPy is the fundamental package for scientific computing with Python , having following important functionalities:
A powerful N-dimensional array object
A sophisticated (broadcasting) functions
Contains tools for integrating C/C++ and Fortran code
Have useful linear algebra, Fourier transform, and random number capabilities
Why NUMpy?
Mathematical and logical operations on arrays.
Efficient storage and manipulation of numerical arrays is which is fundamental in the process of data science.
NumPy arrays form the core of nearly the entire ecosystem of data science tools in Python,
Installation
Anaconda: A free distribution of Python with scientific packages. Supports Linux, Windows and Mac
pip:Most major projects upload official packages to the Python Package index. They can be installed on most operating systems using Python’s standard pip package manager.
You can install packages via one of the following Commands:
Importing Nympy & Checking Version
Bounding numpy package to local variable
The numpy package is bound to the local variable numpy. The import as syntax simply allows you to bind the import to the local variable name of your choice (usually to avoid name collisions, shorten verbose module names, or standardize access to modules with compatible APIs).
Speed Comaprison numpy vs core python
Creating Arrays
The basic ndarray is created using an array function in NumPy which creates an ndarray from any object exposing array interface, or from any method that returns an array.
Array Atrributes
Numpy Arrays are conveinent and fast as compared to Python Lists. 1.Shape(no of rows & columns)
ndim for checking dimension of array
dtype for checking data type of array
Array Initilization
Array Initilization with Random numbers
In various applications( like assigning weights in Artificial Neural Networks) arrays need to be initialised randomly. for this purpose there are various predefined functions in Numpy(reshape and random)
Indexing arrays
Maths
Stats
Binary Universal Functions
Subsetting array
Concatenating Arrays
Broadcasting
Broadcasting is a method to overcome size of the smaller array by duplicacy so that it is the dimensionality and size as the larger array.
Why Broadcasting?
To solve the problem of arithmetic with arrays with different sizes.
Array with different shapes
File Input Output
The storage and retrieval of array data in simple text file format is done with savetxt() and loadtxt() functions.