[Python] How to convert a list of strings into a numeric numpy array?

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

  1. Stack

    Stack Membro Participativo

    I want to be able to calculate the mean, min and max of A:

    import numpy as np

    A = ['33.33', '33.33', '33.33', '33.37']

    NA = np.asarray(A)

    AVG = np.mean(NA, axis=0)

    print AVG


    This does not work, unless converted to:

    A = [33.33, 33.33, 33.33, 33.37]


    Is it possible to perform this conversion automatically?

    Continue reading...

Compartilhe esta Página