top of page
  • Writer's pictureJatin Madaan

Python Numpy Arrays

Updated: Aug 7, 2019


Python objects :

1 . High-level number objects : integers , floating point.

2. Containers : list (Costless insertion and append),dictionaries (fast lookup).


Numpy provides :

1. Extension package to python for multi-dimensional arrays.

2. Closer to hardware (efficiency).

3. Designed for scientific computation (convenience).

4. Also known as array oriented computing.


eg:



Operations :


1. Creation :


Manual Creation of arrays :

eg :



Functions for creating arrays :

eg:



2. Basic Data Type :


eg:



3. Indexing and Slicing :


we can access items the same way we do for lists .

eg:



4. Copies and Views :


A slicing operation creates a view on the original array , which is just a way of accessing array data . Thus the original data is not copied in memory . We can use np.shares_memory() to check if two arrays share the same memory block or not. If memory is shared then if value in one is updated then it reflects on other as well.





5. Fancy Indexing :


Numpy arrays can be indexed with slice , but also with boolean or integer arrays(masks).This method is called fancy indexing . It creates copies and not views.

eg:



6. Basic Elementwise Operations :


Scalar - Element wise operations :

eg :




Comparison : Element-wise and array wise as well.

eg:


Shape and Transcendental functions


eg:


7. Basic Reductions :


eg:



15 views0 comments

Comentarios


bottom of page