- 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
129 Views
To create a record array from a (flat) list of array, use the numpy.core.records.fromarrays() method in Python Numpy. The datatype is set using the "dtype" parameter.It returns the record array consisting of given arrayList columns. The first parameter is a List of arraylike objects (such as lists, tuples, and ndarrays). The dtype is the valid dtype for all arrays. The formats, names, titles, aligned, byteorder parameters, if dtype is None, these arguments are passed to numpy.format_parser to construct a dtype.StepsAt first, import the required library −import numpy as npCreate a new array using the numpy.array() method −arr1 = np.array([[5, 10, ... Read More
83 Views
To AND every element of a masked array by a given scalar value, use the ma.MaskedArray.__iand__() method in Python Numpy. Returns self&=value. A masked array is the combination of a standard numpy.ndarray and a mask. 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.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, ... Read More
150 Views
To expand the shape of an array, use the numpy.expand_dims() method. Insert a new axis that will appear at the axis position in the expanded array shape. The function returns the View of the input array with the number of dimensions increased.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.StepsAt first, import the required library −import numpy as npCreating an array using the array() method −arr = np.array([5, 10, 15, 20, 25, 30])Display the ... Read More
79 Views
To Right Shift every element of a masked array by a given scalar value, use the ma.MaskedArray.__irshift__() method in Python Numpy.A masked array is the combination of a standard numpy.ndarray and a mask. 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.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and ... Read More
234 Views
To produce an object that mimics broadcasting, use the numpy.broadcast() method in Python Numpy. A set of arrays is said to be broadcastable if the above rules produce a valid result and one of the following is true −Arrays have exactly the same shape.Arrays have the same number of dimensions and the length of each dimension is either a common length or 1.Array having too few dimensions can have its shape prepended with a dimension of length 1, so that the above stated property is true.StepsAt first, import the required library −import numpy as npCreate two arrays −arr1 = np.array([[5, ... Read More
111 Views
To Left Shift every element of a masked array by a given scalar value, use the ma.MaskedArray.__ilshift__() method in Python Numpy. A masked array is the combination of a standard numpy.ndarray and a mask. 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.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, ... Read More
87 Views
To roll the specified axis backwards, until it lies in a given position, use the numpy.moveaxis() method in Python Numpy. Here, The 1st parameter is the Input arrayThe 2nd parameter is the axis to be rolled. The positions of the other axes do not change relative to one another.The 3rd parameter is the start i.e. when start axis, the axis is rolled until it lies before this position.StepsAt first, import the required library −import numpy as npCreate an array with ones −arr = np.ones((2, 3, 4, 5))Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions ... Read More
76 Views
To raise each and every element of a masked array to a given scalar value, use the ma.MaskedArray.__ipow__() method in Python Numpy. A masked array is the combination of a standard numpy.ndarray and a mask. 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.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, ... Read More
894 Views
To move axes of an array to new positions, use the numpy.moveaxis() method in Python Numpy. Here, the 1st parameter is the array whose axes should be reordered. The 2nd parameter is the source int or sequence of int i.e. original positions of the axes to move. These must be unique. The 3rd parameter is the destination int or sequence of int. The Destination positions for each of the original axes. These must also be unique.StepsAt first, import the required library −import numpy as npCreate an array with zeros −arr = np.zeros((2, 3, 4))Displaying our array −print("Array...", arr)Get the datatype ... Read More
96 Views
To shift the bits of an integer to the left, use the numpy.left_shift() method in Python Numpy. We have set the count of shifts as a new array.Bits are shifted to the left by appending x2 0s at the right of x1. Since the internal representation of numbers is in binary format, this operation is equivalent to multiplying x1 by 2**x2. The x1 is the Input values. The x2 is the number of zeros to append to x1. Has to be non-negative. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the ... Read More