Skip to main content

Python NumPy Introduction


  • Python is emerging as one of the favorite tools in the filed of data science. With powerful data science libraries like NumPy, SciPy, pandas, matplotlib, scikit-learn and tools like IPython (Jupyter) notebook combined with ease of programming, Python is proven as the powerful and preferred language of organizations.
  • In this course I will tech you the basics of NumPy and further take a deep dig on playing with NumPy.


NumPy :
  • NumPy is a python library, which supports efficient handling of various numerical operations on arrays holding numeric data.
  •  They are known as N-dimensional-arrays or ndarrays. 
  • Ndarrays are capable of holding data elements in multiple dimensions and each data element of it is of fixed size and also all the elements of ndarray are of same data type.
N-dimensional array (ndarray) :
  • N-dimensional array is an object, capable of holding data elements of same type and of fixed size in multiple dimensions.
1-D Array
Example of 1-D array :

import numpy as np
x = np.array([5, 8,  9, 10, 11]) 

type(x)   # Displays type of array 'x'

Output :
numpy.ndarray

2-D Array
Example of 2-D array :
y = np.array([[6, 9, 5], 
              [10, 82, 34]])  
print(y)

Output :
array([[ 6,  9,  5],
       [10, 82, 34]])

Comments

Popular posts from this blog

Python File

File handling is the most important part of any Web Applications. This has several functions for creating, reading, updating, deleting files etc., File Handling:           The key for working with files in Python is the open() function. Syntax: open(filename, mode) There are four different methods for opening a file: "r" - Read - Default value. Opens a file for reading, error if the file does not exist. "a" - Append - Opens a file for appending, creates the file if it does not exist. "w" - Write - Opens a file for writing, creates the file if it does not exist. "x" - Create - Creates the specified file, returns an error if the file exists. In addition you can specify if the file should be handled as binary or text mode: "t" - Text - Default value. Text mode. "b" - Binary - Binary mode(e.g., images) Note: Make sure the file exists, or else you will get an error. Syntax: f = ...

LISTS in Python

One of the basic data structures in Python is sequences. There are six built-in types of sequence - strings, Unicode strings, lists, tuples, buffers, and xrange objects. The most common are lists and tuples.  A list is an ordered set of values, where each value is identified by an index. The values in the list are known as elements. Each element of a sequence is assigned with a number - its position or index. The first index is zero, second is one and so forth. Creation and Accessing List: The list can be created by putting values separated by commas between square brackets []. List is one of the most freuently used and very versatile data type used in Python.  Syntax for List:                <List_name> = [<Value_1>,<Value_2>,........,<Value_N>] NOTE:  Nested lists are also acceptable. List Operations: Two operations + and * is allowed in list. + for concatenation ...