Home > other >  Bits, python reads text data to the two dimensional array, have what good method
Bits, python reads text data to the two dimensional array, have what good method

Time:05-25

 
Data=https://bbs.csdn.net/topics/[]
With the open ('./data/housing. CSV ', 'r') as f:
For idata in f:
Data. Append (re. Sub (' + ', ' ', idata. Strip ()). The split (" ")) # multiple space-delimited floating-point
Data=https://bbs.csdn.net/topics/np.array (data)

X_train, Y_train=data [:, 5], the data [: len (data [1]) - 1)

FloatArr=[]
For I in X_train:
FloatArr. Append (float (I))
X_train=floatArr

FloatArr=[]
For I in Y_train:
FloatArr. Append (float (I))
Y_train=floatArr

This can be achieved, but the feeling is very low, similar to the C language (before learn C, just turn to python), python is not as elegant, this elegant implementation?