- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1204 Articles for Numpy
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
159 Views
To return the variance of the masked array elements, use the ma.MaskedArray.var() in Python Numpy. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.The “axis” parameter is the axis or axes along which the variance is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. The dtype is the type to ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
290 Views
To shift the bits of array elements of a 2d array to the right, use the numpy.right_shift() method in Python Numpy. Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.The x1 is the Input values. The x2 is the number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape.The function right_shift() returns x1 with bits shifted x2 times to the right. This is a scalar if both x1 and x2 are ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
81 Views
To shift the bits of an integer to the right, use the numpy.right_shift() method in Python Numpy. We have set the count of shifts as a new array. Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.The x1 is the Input values. The x2 is the number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape.The function right_shift() returns x1 with bits shifted x2 times to the right. This is a ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
221 Views
To return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa, use the numpy.char.swapcase() method in Python Numpy. For 8-bit strings, this method is locale-dependent.The function swapcase() returns an output array of str or unicode, depending on input type. The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_ or numpy.bytes_.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['Katie', 'JOHN', 'Kate', 'AmY', 'brADley']) Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
76 Views
To return a copy of an array with the leading and trailing characters removed, use the numpy.char.strip() method in Python Numpy. The "chars" parameter is used to set a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix; rather, all combinations of its values are stripped.The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_ or numpy.bytes_.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of string with some leading and trailing characters ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
93 Views
To return the sum along diagonals of the masked array elements, use the ma.MaskedArray.trace() in Numpy. The offset parameter is the offset of the diagonal from the main diagonal. Can be both positive and negative. Defaults to 0.The axis 1 and axis 2 are the axes to be used as the first and second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults are the first two axes of a. The dtype determines the data-type of the returned array and of the accumulator where the elements are summed. If dtype has the value None and a ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
To convert masked array to float type, use the ma.MaskedArray.__float__() method in Numpy. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an array using the numpy.array() method −arr = np.array([30]) print("Array...", arr) print("Array type...", arr.dtype)Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Create a masked array −maskArr = ma.masked_array(arr, mask =[False]) print("Our Masked Array", maskArr) print("Our Masked Array type...", ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
81 Views
To get the imaginary part from the masked array, use the ma.MaskedArray.imag attribute in Numpy. This property is a view on the imaginary part of this MaskedArray.A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreating an array of complex number elements using the numpy.array() method −arr = np.array([68.+4.j , 49.+7.j , 120.+2.j , 64.+0.j]) print("Array..", arr) print("Get the imaginary part", ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
88 Views
To get the Tuple of bytes to step in each dimension when traversing an array, use the ma.MaskedArray.strides attribute in Numpy. The byte offset of element (i[0], i[1], ..., i[n]) in an array a is −offset = sum(np.array(i) * a.strides)A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an array using the numpy.array() method −arr = np.array([[35, 85], [67, 33]]) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
579 Views
To get the total bytes consumed by the masked array, use the ma.MaskedArray.nbytes attribute in Numpy. Does not include memory consumed by non-element attributes of the array object.A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an array using the numpy.array() method −arr = np.array([[35, 85], [67, 33]]) print("Array...", arr) print("Array type...", arr.dtype) print("Array itemsize...", arr.itemsize)Get the dimensions of the ... Read More