numpy.ix_() function

Calling method:

numpy.ix_(*args)

The meaning of each parameter

args: 1-D sequences, which should be integers or booleans.
There is a return value, and an ndarray tuple is returned. The tuple returned by n arrays is n-dimensional

code show as below:

# -*- coding:utf-8 -*-
"""
author: 15025
time: 2020/11/19 12:21
software: PyCharm

Description:
"""
import numpy as np


class Numpy:
    @staticmethod
    def mainProgram():
        array = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
        index = np.ix_([0, 1], [2, 4])
        print("array为: ")
        print(array[index])


if __name__ == "__main__":
    n = Numpy()
    n.mainProgram()
"""
array为: 
[[ 3  5]
 [ 8 10]]
"""

Guess you like

Origin blog.csdn.net/u011699626/article/details/110009835