vendredi 26 juillet 2019

Why this function couldn't return right result?

Result is not same actual values.For example, in this case from my output only first observation is same as actual.

 import numpy as np
    np.random.seed(0)
    def emil(values):
        output = np.empty(len(values))
        for i in range(len(values)):
            output[i] = 1.0 / values[i]
            print(len(values))
            return output
    values = np.random.randint(1, 10, size=6)
print(emil(values))

Out[1]: array([ 0.16666667, 1. , 0.25 , 0.25 , 0.125 ])




Aucun commentaire:

Enregistrer un commentaire