Search

Showing posts with label Numpy. Show all posts
Showing posts with label Numpy. Show all posts

12 June, 2018

Exploring Numpy

What can we really do with Numpy? Why should we use it at all ?

Start with : import numpy

1. We can create arrays .


method: numpy.array(object, dtype=None, copy=True, order='K', subok=False, ndmin=0)


>>> a = numpy.array(range(10))
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a.dtype
dtype('int32')

In the above array, there are 10 columns and 1 row.

Note : The concept of rows and columns applies when you have a 2D array. However, the array numpy.array([1,2,3,4]) is a 1D array and so has only one dimension, therefore shape rightly returns a single valued iterable.

Refer this link