Python 'numpy.ndarray' 对象没有属性 'values'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41560021/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'numpy.ndarray' object has no attribute 'values'
提问by T.Setso
I want to shift my time series data, but getting following error:
我想移动我的时间序列数据,但出现以下错误:
AttributeError: 'numpy.ndarray' object has no attribute 'values'
AttributeError: 'numpy.ndarray' 对象没有属性 'values'
Thats my Code:
那是我的代码:
def create_dataset(datasets):
#series = dataset
temps = DataFrame(datasets.values)
dataframes = concat(
[temps, temps.shift(-1), temps.shift(-2), temps.shift(-3)], axis=1)
lala = numpy.array(dataframes)
return lala
#load
dataframe = pandas.read_csv('zahlenreihe.csv', index_col=False,
engine='python', header=None)
dataset = dataframe.values
dataset = dataset.astype('float32')
#split
train_size = int(len(dataset) * 0.70)
test_size = len(dataset) - train_size
train, test = dataset[0:train_size,:], dataset[train_size:len(dataset),:]
#create
trainX = create_dataset(train)
I think the following line is wrong:
我认为以下行是错误的:
temps = DataFrame(datasets.values)
My zahlenreihe.csv just has integers ordered like:
我的 zahlenreihe.csv 只有整数排序如下:
1
2
3
4
5
n
How should i handle it?
我该如何处理?
回答by T.Setso
The solution: the given dataset was already an array, so I didnt need to call .value.
解决方案:给定的数据集已经是一个数组,所以我不需要调用.value。