numpy 二维直方图
numpy 2D Histogram
当我运行:
hist_2d_i = np.histogram2d(df.feature1.iloc[0], df.feature2.iloc[0], bins=\
[binsx, binsy],weights=df.weights.iloc[0])
我收到一个错误:
bin 的维度必须等于样本 x 的维度。
但是如果我运行:
hist_2d_i = np.histogram2d(df.feature1.iloc[0:1], df.feature2.iloc[0:1], bins=\
[binsx, binsy],weights=df.weights.iloc[0:1])
它按预期工作。有什么区别?
索引 运行s 通过 pandas 数据帧数据集中的样本数。
[0] == [0:1]
不是索引吗?
[0]
是数组的第一个元素,而 [0:1]
是只包含第一个元素的数组。
当我运行:
hist_2d_i = np.histogram2d(df.feature1.iloc[0], df.feature2.iloc[0], bins=\
[binsx, binsy],weights=df.weights.iloc[0])
我收到一个错误: bin 的维度必须等于样本 x 的维度。
但是如果我运行:
hist_2d_i = np.histogram2d(df.feature1.iloc[0:1], df.feature2.iloc[0:1], bins=\
[binsx, binsy],weights=df.weights.iloc[0:1])
它按预期工作。有什么区别?
索引 运行s 通过 pandas 数据帧数据集中的样本数。
[0] == [0:1]
不是索引吗?
[0]
是数组的第一个元素,而 [0:1]
是只包含第一个元素的数组。