setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (5115, 2) + inhomogeneous part. File "C:\Users\lenovo\Desktop\实习\import pandas as pd.py", line 59, in TS_SUM array = np.array(array).flatten() ^^^^^^^^^^^^^^^ File "C:\Users\lenovo\Desktop\实习\import pandas as pd.py", line 90, in STOM result=TS_SUM(array=free_turn,number=21) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\lenovo\Desktop\实习\import pandas as pd.py", line 119, in <module> print(STOM(data=sto)) ^^^^^^^^^^^^^^ ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (5115, 2) + inhomogeneous part.
时间: 2023-08-05 11:07:11 浏览: 275
这个错误通常出现在尝试将一个不均匀形状的序列设置为数组元素时。在你的代码中,错误发生在第 59 行,当你尝试使用 `np.array(array).flatten()` 将数组展平时。该错误传播到第 90 行,最终导致第 119 行的错误。
要解决这个问题,你需要确保将相同形状的元素添加到数组中。检查 `array` 变量的内容,确保每个元素都具有相同的形状。如果不是相同形状,你可以考虑调整数据的结构或使用其他数据结构来存储你的数据。
阅读全文