Skip to content
  • Tutorials
    • c programming
      • libraries
    • c++
    • Linux
    • Python
    • batch programming
    • Technology
  • IDE
  • Tools
string array to float array python 1

string array to float array python

May 10, 2022 by Anurag batra
import numpy as np
x = np.array(['1.1', '2.2', '3.3'])
y = x.astype(np.float)

Here is what the above code is Doing:
1. Creating an array of strings
2. Converting the array of strings to an array of floats

The output of the above code is:

array([ 1.1, 2.2, 3.3])

Categories Python Examples
Post navigation
how to run python file in when windows startup
discord.py unmute
© MyEduKit - 2022 . All Rights Reserved.