Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
NumPy Essentials

You're reading from  NumPy Essentials

Product type Book
Published in Apr 2016
Publisher
ISBN-13 9781784393670
Pages 156 pages
Edition 1st Edition
Languages
Authors (3):
Leo (Liang-Huan) Chin Leo (Liang-Huan) Chin
Profile icon Leo (Liang-Huan) Chin
Tanmay Dutta Tanmay Dutta
Profile icon Tanmay Dutta
Shane Holloway Shane Holloway
Profile icon Shane Holloway
View More author details

Table of Contents (16) Chapters

NumPy Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
An Introduction to NumPy The NumPy ndarray Object Using NumPy Arrays NumPy Core and Libs Submodules Linear Algebra in NumPy Fourier Analysis in NumPy Building and Distributing NumPy Code Speeding Up NumPy with Cython Introduction to the NumPy C-API Further Reading

Array data types


Data types are another important intrinsic aspect of a NumPy array alongside its memory layout and indexing. The data type of a NumPy array can be found by simply checking the dtype attribute of the array. Try out the following examples to check the data types of different arrays:

In [49]: x = np.random.random((10,10)) 
 
In [50]: x.dtype 
Out[50]: dtype('float64') 
In [51]: x = np.array(range(10)) 
 
In [52]: x.dtype 
Out[52]: dtype('int32') 
 
In [53]: x = np.array(['hello', 'world']) 
 
In [54]: x.dtype 
Out [54]: dtype('S5') 

Many array creation functions provide a default array data type. For example, the np.zeros and np.ones functions create arrays that are full of floats by default. But it is possible to make them create arrays of other data types too. Consider the following examples that demonstrate how to use the dtype argument to create arrays of arbitrary data types.

In [55]: x = np.ones((10, 10),...
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 $15.99/month. Cancel anytime}