Hi,

In DataFrames, it is easy to apply a function by columns using the colwise() 
function. But I find very difficult and inefficient to apply a function by 
rows.

For example :


 
 julia> df = DataFrame(a=1:5, b=7:11, c=10:14) 
5x3 DataFrames.DataFrame 
| Row | a | b  | c  | 
|-----|---|----|----| 
| 1   | 1 | 7  | 10 | 
| 2   | 2 | 8  | 11 | 
| 3   | 3 | 9  | 12 | 
| 4   | 4 | 10 | 13 | 
| 5   | 5 | 11 | 14 | 

 
 
 julia> colwise(mean,df) 
3-element Array{Any,1}: 
 [3.0]  
 [9.0]  
 [12.0]
 
 
 julia> colwise(mean,df[1,1:2]) 
2-element Array{Any,1}: 
 [1.0] 
 [7.0]



To calculate the mean of a row (or a subset), the only way I found is this :

julia> mean(convert(Array,df[1,1:3])) 
6.0
 


I think this is inefficient and probably very slow. I there a better way to 
apply a function by rows ?

Thanks !

Reply via email to