Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
IPython Notebook Essentials

You're reading from   IPython Notebook Essentials Compute scientific data and execute code interactively with NumPy and SciPy

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783988341
Length 190 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Luiz Felipe Martins Luiz Felipe Martins
Author Profile Icon Luiz Felipe Martins
Luiz Felipe Martins
Arrow right icon
View More author details
Toc

Array creation and member access

NumPy arrays are objects of the ndarray class, which represents a fixed-size multidimensional collection of homogeneous data.

Here, we will assume that the NumPy library has been imported using the following command line:

import numpy as np

Once we have done that, we can create ndarray (from now on, informally called array object or simply array) from a list of lists as indicated in the following command line:

a = np.array([[-2,3,-4,0],[2,-7,0,0],[3,-4,2,1]],dtype=np.float64)
print a

Contrary to Python lists and tuples, all entries of an array object must be of the same type. The types themselves are represented by NumPy objects and are referred to as dtype (from data type) of the array. In the preceding example, we explicitly specify dtype as float64, which represents a 64-bit floating-point value.

Arrays have several attributes that give information about the data layout. The more commonly used ones are as follows:

  • The shape of the array is computed using...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image