numpy.ascontiguousarray() is used when we want to return a contiguous array in memory (order C).
Syntax: numpy.ascontiguousarray (arr, dtype = None)
arr: [array_like] Input data , in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
dtype: [str or dtype object, optional] Data-type of returned array .
Return: ndarray Contiguous array of same shape and content as arr, with type dtype if specified.
Code no. 1: list to array
| tr> |
Input list: [100, 200, 300 , 400, 500] output array from input list: [100.200.300.400.50 0.]
Code # 2: tuple to array
Input touple: ([2, 6, 10], [8, 12, 16]) output array from input touple: [[ 2 6 10] [8 12 16]]
Code # 3: Scalar to Array
| tr> |
Input scalar: 100 output array from input scalar: [100.] class 'numpy.ndarray'
We are witnessing a movement that will completely transform any part of business and society. The word we have given to this move- ment is Big Data and it will change everything, from the way banks an...
Data and storage models are the basis for big data ecosystem stacks. While storage model captures the physical aspects and features for data storage, data model captures the logical representation and...
You should understand the basics of development and usage atop Apache Spark. This book will not be covering introductory material. There are numerous books, forums, and resources available that cover ...
Mastering regular expressions by Jeffrey Friedl, 3rd edition. Regular expressions are an extremely powerful tool for manipulating text and data. They are standard features today in a variety of pop...