JuliaStats/DataFrames.jl — pull request #349 by nfoti (2013-08-14 15:20:57+00:00)
Title: WIP: mapslices for DataFrame.

This is a first pass at extending `colwise` to be able to apply a function to the columns or rows of a `DataFrame`. I've implemented `mapslices(f, df, dim)` that applies the function `f` to the `DataFrame` `df` along the dimension `dim`. I thought this interface more closely resembles the analogous functions in `Base` as opposed to `colwise` and `rowwise`.

I have only implemented `mapslices` to apply a single function (which can be specified with a `Symbol`) to a `AbstractDataFrame` and `GroupedDataFrame`. One question is what should the function for `GroupedDataFrame` return? Currently I return an `Array{DataFrame}` but maybe these functions should return what `based_on` does? Also, `mapslices(f, df, 2)` (that is row-wise application) assumes `f` is defined for a `DataFrame`. Lastly, I didn't implement versions that allow vectors of functions to be applied to the rows/columns of a `DataFrame` because I wasn't sure what the optimal behavior was. Should they return an `Array{DataFrame}` where each entry is the result of applying the corresponding function to the rows/columns? This seems intuitive, but if there are other ideas I'd like to hear them.

Thanks.