I have a file below
label,feature
0,70 80 90 50 33 58 ...
2,53 56 84 56 25 12 ...
1,32 56 84 89 65 87 ...
...
2,56 48 57 56 99 22 ...
4,25 65 84 54 54 15 ...
I want the data could be
Ytrain = [0,2,1,...2,4] (int, ndarray)
Xtrain = [[70 80 90 50 33 58...],
[53 56 80 56 25 12...],
...
[25 65 84 54 54 15...]] (int, ndarray)
here is my code
data = pd.read_csv('train.csv')
Ytrain = np.array(data.iloc[:, 0]).astype(int)
train = np.array(data.iloc[:, 1:]).astype(str)
Xtrain = []
for i in range(len(train)):
tmp = [int(x) for x in train[i][0].split()]
Xtrain.append(tmp)
Xtrain = np.array(Xtrain)
do you have a better way to do that ?