This is not a technical question. Consider it esthetechnical. While all functions from the DataFrames module get a DataFrame as first parameter, why don’t “Filter” and “Map” get this treatment too ?
Why filter(function, df::AbstractDataFrame)
but not filter(df::AbstractDataFrame, function)
?
That’s just the way filter works in general - DataFrame strives for consistency with Julia base where possible:
help?> filter
search: filter filter! fieldtype fieldtypes
filter(f, a)
Return a copy of collection a, removing elements for which f is false. The function f is passed one argument.
Note that in the development version of DataFrames (to be released as 1.0), a new subset function is provided which is more consistent with other DataFrames functions.
Since no one’s mentioned it, just to expand that the reason Base functions that take in a function argument put that function argument first (see also map, reduce, broadcast, etc…) is so that you can use those functions with do blocks, like
filter(1:10) do x
4 < x < 7
end
since the do block creates an anonymous function and then by convention passes it as the first argument to the function.