ValueError: setting an array element with a sequence.

太过爱你忘了你带给我的痛 2022-08-04 12:45 157阅读 0赞

http://[blog.csdn.net/pipisorry/article/details/48031035][blog.csdn.net_pipisorry_article_details_48031035]

From the code you showed us, the only thing we can tell is that you trying to create an array from a list that isn’t shaped like a multi-dimensional array. For example

  1. numpy.array([[1,2], [2, 3, 4]])

or

  1. numpy.array([[1,2], [2, [3, 4]]])

will yield this error message, because the shape of the input list isn’t a (generalised) “box” that can be turned into a multidimensional array. So probably UnFilteredDuringExSummaryOfMeansArraycontains sequences of different lengths.

Edit: Another possible cause for this error message is trying to use a string as an element in an array of type float:

  1. numpy.array([1.2, "abc"], dtype=float)

That is what you are trying according to your edit. If you really want to have a NumPy array containing both strings and floats, you could use the dtype object, which enables the array to hold arbitrary Python objects:

  1. numpy.array([1.2, "abc"], dtype=object)

Without knowing what your code shall accomplish, I can’t judge if this is what you want.

皮皮Blog

ps:array 未对齐,先查看array是否对齐,可能是数据集末尾行存在多余行

http://stackoverflow.com/questions/4674473/valueerror-setting-an-array-element-with-a-sequence

http://blog.csdn.net/pipisorry/article/details/23563441

from: http://blog.csdn.net/pipisorry/article/details/48031035
ref:

发表评论

表情:
评论列表 (有 0 条评论,157人围观)

还没有评论,来说两句吧...

相关阅读