Python numpy.historogramdd:ValueError:存储箱的尺寸必须等于样本x的尺寸

Python numpy.historogramdd:ValueError:存储箱的尺寸必须等于样本x的尺寸,python,numpy,histogram,Python,Numpy,Histogram,我遇到了一个无法解释的错误。如果我使用列表作为输入,它会工作,但如果我将转换为numpy数组的相同列表馈送给它,它会失败: ValueError: The dimension of bins must be equal to the dimension of the sample x. 为什么会这样?我使用的是python3.7.5,numpy1.17.3 import numpy as np bin_edges = np.array([ [10.08, 11.25454545,

我遇到了一个无法解释的错误。如果我使用列表作为输入,它会工作,但如果我将转换为
numpy
数组的相同列表馈送给它,它会失败:

ValueError: The dimension of bins must be equal to the dimension of the  sample x.
为什么会这样?我使用的是
python3.7.5,numpy1.17.3

import numpy as np

bin_edges = np.array([
    [10.08, 11.25454545, 12.42909091, 13.60363636, 14.77818182,
     15.95272727, 17.12727273, 18.30181818, 19.47636364, 20.65090909,
     21.82545455, 23.],
    [-0.03, 0.18, 0.39, 0.6, 0.81, 1.02, 1.23, 1.44, 1.65, 1.86],
    [-0.54, -0.27222222, -0.00444444, 0.26333333, 0.53111111, 0.79888889,
     1.06666667, 1.33444444, 1.60222222, 1.87]])

arr = [[17.10827794, 11.83391358, 12.83095133, 22.95133446, 10.56728914,
        10.79192481, 16.44720125, 15.6446372, 20.89509702, 11.20721727],
       [15.45189, 22.95207101, 19.59385685, 23.25150156, 11.46710741,
        23.48013989, 10.77612015, 12.9927327, 21.71852366, 22.60270056],
       [22.94057217, 18.50618166, 13.21763666, 10.82516534, 17.54735419,
        13.48076389, 17.82794113, 14.31666433, 11.71345638, 16.17708158]]

# This works
hst = np.histogramdd(arr, bins=bin_edges)

# This fails
arr = np.array(arr)
hst = np.histogramdd(arr, bins=bin_edges)
根据:

示例:(N,D)数组或(D,N)类数组

因此,它必须是:

arr = np.array(arr)
hst = np.histogramdd(arr.T, bins=bin_edges)

啊,为什么?谢谢你Stefseem对我来说也很奇怪但事实上我不知道是什么原因