OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

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

  • Thread starter Thread starter Cristian J Estrada
  • Start date Start date
C

Cristian J Estrada

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

Code:
 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:

Code:
A = [33.33, 33.33, 33.33, 33.37]

Is it possible to perform this conversion automatically?
<p>I want to be able to calculate the mean, min and max of <code>A</code>:</p>

<pre><code> 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
</code></pre>

<p>This does not work, unless converted to:</p>

<pre><code>A = [33.33, 33.33, 33.33, 33.37]
</code></pre>

<p>Is it possible to perform this conversion automatically?</p>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top