explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Split filter/2 in two functions

Open josevalim opened this issue 2 years ago • 5 comments

@cigrainger I was wondering if we should break filter/2 in two functions: mask(dataframe, series) and filter(dataframe, callback).

The rationale for doing so is that we don't want to encourage filter(dataframe, series), as that won't be efficient as a lazy query. So I thought we should make filter/2 to be exclusively function based (and across based in the future based on #223) and provide a specific mask/2 function for masking.

Thoughts?

josevalim avatar May 07 '22 16:05 josevalim

Sorry I meant to say ages ago that I agree with this. Mask is perfect.

cigrainger avatar Jul 07 '22 05:07 cigrainger

@cigrainger so last time we talked we were not sure if we should allow the mask in filter_with (instead of filter) or introduce the mask function. Between those options, any preference?

The mask in filter_with doesn't have the ambiguity this issue first comments on... so it may be theoretically fine, although some adapters like SQL cannot implement the mask version anyway.

josevalim avatar Jul 07 '22 05:07 josevalim

I think a separate mask function makes more sense to me. It seems cleaner. But I don't hold a strong opinion on this one. How much do we think folks should use filter_with directly?

cigrainger avatar Jul 07 '22 08:07 cigrainger

Once we land the macro version of filter/2, there is little to no reason to use filter_with/2? So yeah, it makes sense to have mask/2 then!

josevalim avatar Jul 07 '22 08:07 josevalim

Agreed! Let's do it.

cigrainger avatar Jul 07 '22 10:07 cigrainger