[Python] Convert 3 column tabular data to a numpy matrix with transformation

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    Could some one help me out with an efficient solution to convert a tabular data into a numpy matrix?

    The input is tabular data with header in the following format:

    D1​
    D2​
    Value​
    A​
    B​
    1​
    C​
    D​
    2​
    E​
    F​
    3​
    A​
    D​
    1​
    E​
    B​
    4​

    The desired output is a numeric numpy array:

    1​
    2
    2
    4​
    3​

    Here, D1 column values of table "transforms" to rows in the array (representing A/C/E in order) and D2 column values of table "transforms" to column in the array (representing B/D/F in order) and the values are arranged appropriately.

    Continue reading...

Compartilhe esta Página