在处理数据集时,尤其是使用机器学习或数据科学工具包(如Pandas)时,我们有时会遇到“TypeError: Unexpected type <class ‘numpy.ndarray‘>”的错误。这个错误通常意味着你尝试将一个NumPy数组用作它不能处理的类型。让我们来分析一下可能的原因和解决方案。 原因分析 数据类型不匹配:你可能正在尝试将一个NumPy
numpy: <class 'numpy.ndarray'> (1000000,) >f4 nan: (array([], dtype=int64),) total: 499.99963 --- cupy: <class 'cupy.core.core.ndarray'> (1000000,) >f4 nan: (array([ 213, 385, 426, ..., 999227, 999242, 999391]),) total: nan The numpy array shows no NaNs as expected...
X_test, y_train, and y_test (I'm working with time series data, which is why I can't use train_test_split, and TimeSeriesSplit doesn't work when X is a pandas dataframe so I need to turn it into a numpy array).