3
比方說,我有一個數據框包含幾個分類維度和一個「值」維度,我想通過其中的一些來聚合,忽略其他維度。如何讓函數聚合「忽略」列?
在朱莉婭DataFrames有功能聚集,但如果我讓出部分categarical值我得到一個錯誤,因爲它試圖功能(這裏的總和)也適用於他們,而不是僅僅忽略它們:
在:
using DataArrays, DataFrames
df = DataFrame(
colour = ["green","blue","white","green","green"],
shape = ["circle", "triangle", "square","square","circle"],
border = ["dotted", "line", "line", "line", "dotted"],
area = [1.1, 2.3, 3.1, 4.2, 5.2])
日期:
colour shape border area
1 green circle dotted 1.1
2 blue triangle line 2.3
3 white square line 3.1
4 green square line 4.2
5 green circle dotted 5.2
在:
aggregate(df,[:colour,:shape, :border],sum) # Ok
aggregate(df,[:colour,:shape],sum) # what I would like, ignoring border column
日期:
LoadError: MethodError: no method matching +(::String, ::String)
很顯然,我可能只是聚集之前刪除多餘的列,但也許有一種方法可以做到在一個單一的通道?