{"id":27552,"date":"2022-08-30T21:06:27","date_gmt":"2022-08-30T15:36:27","guid":{"rendered":"https:\/\/python-programs.com\/?p=27552"},"modified":"2022-08-30T21:06:27","modified_gmt":"2022-08-30T15:36:27","slug":"python-numpy-matrix-partition","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-numpy-matrix-partition\/","title":{"rendered":"Python Numpy matrix.partition() Function"},"content":{"rendered":"

NumPy Library\u00a0<\/strong><\/p>\n

NumPy is a library in python that is created to work efficiently with arrays in python. It is fast, easy to learn, and provides efficient storage. It also provides a better way of handling data for the process. We can create an n-dimensional array in NumPy. To use NumPy simply have to import it into our program and then we can easily use the functionality of NumPy in our program.<\/p>\n

NumPy is a Python library that is frequently used for scientific and statistical analysis. NumPy arrays are grids of the same datatype\u2019s values.<\/p>\n

Numpy matrix.partition() Function:<\/strong><\/p>\n

Using the matrix.partition() method of the Numpy module, we can partition the matrix in such a manner that the index value that we pass sorts the matrix in such a way that all the values smaller than that value are moved to the left, and others are moved to the right.<\/p>\n

Syntax:<\/strong><\/p>\n

 matrix.partition(index)<\/pre>\n

Return Value:<\/strong><\/p>\n

The partitioned matrix is returned by the partition() function.<\/p>\n

Numpy matrix.partition() Function in Python<\/h2>\n

For 1-Dimensional (1D) Matrix(array)<\/strong><\/p>\n

Approach:<\/strong><\/p>\n