i want this
array([[2600, 11749, 9], [976, 16, 2, ...],...)
But I don't know why single quotes are printed. What should I do?
CodePudding user response:
It seems that numpy arrays of different lengths have been entered into the pandas series.
It seems that numpy arrays of different lengths have been entered into the pandas series.
try this
X_train.values
or
list(map(np.array, x_train))
CodePudding user response:
It looks like each row in X_train
is a string rather than a list, so I think you need to convert those strings to lists. I think this should do it:
X_train = pd.Series([[int(x) for x in string.strip('[]').split(',')] for string in X_train.tolist()])