[Python] Map numpy categorical data to a numpy vector

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am having a numpy array that is looking like:

    my_arr = array([[0., 0., 0., 0., 1., 0.],
    [0., 1., 0., 0., 0., 0.],
    [0., 0., 0., 1., 0., 0.],
    [0., 0., 0., 0., 1., 0.],
    [1., 0., 0., 0., 0., 0.],
    [0., 0., 0., 0., 1., 0.],
    [0., 1., 0., 0., 0., 0.],
    [0., 0., 0., 0., 1., 0.],
    ...
    ...]


    I want to return a vector that will contain for each vector of my_arr the index of entry with value one. How can I do so?

    Continue reading...

Compartilhe esta Página