¿Cómo hago para normalizar el contenido de una matriz? He aplicado el siguiente código:
import pandas as pd
import numpy as np
from sklearn.preprocessing import normalize
from matplotlib import pyplot as plt
data=pd.read_csv('matriz.txt',header=1,delim_whitespace=True)
df=pd.DataFrame(data)
dfs=normalize(data,axis=0,norm="max")
este es el contenido de matriz.txt:
carga posicion
-1907,64368327896 0,00000000000
-1837,39223105174 0,01741273261
-1696,36408581261 0,06147204306
-1541,86454926361 0,10868110739
-1420,20896667520 0,15785246496
-1274,32440011090 0,21273399758
-1026,77200413398 0,29832991759
-767,24156508194 0,42684021402
-466,67018352329 0,57492888126
-175,59776009596 0,72938611054
108,12377328260 0,90523214103
428,82152553734 1,11148908242
801,08033207679 1,35600803960
1175,60246306842 1,63829757054
1554,83607888089 1,93286986181
1960,59682831716 2,22884388967
2378,62282214488 2,52855148177
2809,27139236284 2,83569535969
3263,19815965902 3,16205967770
3689,46332739113 3,52969392718
3898,73942758306 4,02315085170
3963,28226513050 4,74165696716
4009,88741885059 5,71171991204
4045,04100741374 5,71171991204
3881,99640177727 6,90323789726
3624,88806962117 8,21939187747
3471,25257249604 9,54897062405
Pero obtengo el siguiente error:
ValueError Traceback (most recent call last)
<ipython-input-36-14296e1fec31> in <module>()
6 data=pd.read_csv('matriz.txt',header=1,delim_whitespace=True)
7 df=pd.DataFrame(data)
----> 8 dfs=normalize(data,axis=0,norm="max")
~\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in normalize(X, norm, axis, copy, return_norm)
1410
1411 X = check_array(X, sparse_format, copy=copy,
-> 1412 estimator='the normalize function', dtype=FLOAT_DTYPES)
1413 if axis == 0:
1414 X = X.T
~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
431 force_all_finite)
432 else:
--> 433 array = np.array(array, dtype=dtype, order=order, copy=copy)
434
435 if ensure_2d:
ValueError: could not convert string to float: '9,54897062405'