Yes, you won't believe it, but i've been browsing for two hours for a simple line of code. HOW DO YOU convert DataFrame full of strings to float Dataframe. Even more, how do you convert DataFrame full of string to np.array? There seems to be two solutions which are being suggested over and over - convert objects and astype. None of them work.....
database = pd.read_csv('test1.csv',header=None)
database
Out[165]:
0
0 0,0,1,0,0
1 1,0,1,0,0
2 0,4,0,1,0
3 1,4,0,1,0
4 1,1,0,0,1
5 2,1,0,0,1
database = database.astype(str).convert_objects(convert_numeric=True)
x = np.array(database)
In [170]:
x
Out[170]:
array([['0,0,1,0,0'],
['1,0,1,0,0'],
['0,4,0,1,0'],
['1,4,0,1,0'],
['1,1,0,0,1'],
['2,1,0,0,1']], dtype=object)
OR
DATA = database.astype(float)
ValueError: could not convert string to float: '2,1,0,0,1'