Advance Python Unit - 2
Advance Python Unit - 2
5 subok The returned array will be base class array by default. We can change
this to make the subclasses passes through by setting this option to
true.
6 ndmin It represents the minimum dimensions of the resultant array.
numpy.asarray
This function is similar to numpy.array except for the fact that it has fewer
parameters. This routine is useful for converting Python sequence into ndarray.
◦ numpy.asarray(a, dtype = None, order = None)
The constructor takes the following parameters.
a: Input data in any form such as list, list of tuples, tuples, tuple of tuples or tuple
of lists
dtype: By default, the data type of input data is applied to the resultant ndarray
order: C (row major) or F (column major). C is default
Example 1
◦ # convert list to ndarray
◦ import numpy as np
◦ x = [1,2,3]
◦ a = np.asarray(x)
◦ print a
Its output would be as follows −
◦ [1 2 3]
PARAMETER DESCRIPTION
SN Operator Description
1 bitwise_and It is used to calculate the bitwise and operation between
the corresponding array elements.
◦ # initializing list
◦ li = [1, 2, 3, 3, 2, 2, 2, 1]
x = np.where(arr%2 == 0)
print(x)
output
◦ (array([1, 3, 5, 7]),)