[英]numpy 2D Histogram
當我跑步時:
hist_2d_i = np.histogram2d(df.feature1.iloc[0], df.feature2.iloc[0], bins=\
[binsx, binsy],weights=df.weights.iloc[0])
我收到一個錯誤:箱的尺寸必須等於樣本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])
它按預期工作。 有什么區別?
索引遍歷熊貓數據框數據集中的樣本數。
[0] == [0:1]
不是索引嗎?
[0]
是數組的第一個元素,而[0:1]
是僅包含第一個元素的數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.