Unit 21Creating Arrays

numpy arrays are more compact and faster than native Python lists, especially in multidimensional cases. However, unlike lists, arrays are homogeneous: you cannot mix and match array items that belong to different data types.

There are several ways to create a numpy array. The function array creates an array from array-like data. The data can be a list, a tuple, or another array. numpy infers the type of the array elements from the data, unless you explicitly pass the dtype parameter. numpy supports close to twenty data types, such as bool_, int64, uint64, float64, and <U32 (for Unicode strings).

When numpy creates an array, it doesn’t copy the data from the source to the new array, but it links to it for efficiency ...

Get Data Science Essentials in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.