Allow replacing with results of a function#176
Allow replacing with results of a function#176paulvictor wants to merge 2 commits intoJuliaStats:masterfrom
Conversation
Use case: Replace with samples drawn from the distribution of non NA values
|
Thanks, but I'm not sure a dedicated function and type are really needed here. I find an explicit loop clearer, and almost as short as your version: [isna(dv, i) ? mean(dropna(dv)) : dv[i] for i in eachindex(dv)]or the in-place version for i in eachindex(dv)
if isna(dv, i) dv[i] = m end
end
`` |
|
True, but that's the case with each_replacena too, here the example given seems simple, but given that a function can be used opens up a number of use cases, like replacing NA's with values drawn from a distribution described by the non-NA values(which need not be the same for each invocation), here again, this can be replaced by the transformation as you described, but I find this style better, since you make it more declarative(by passing the function(the what)) than imperative(generating and assigning the values(the how)). On a note aside, there are tests failing on travis and the coverage has been reported to be down, but no test errors occur when I build locally, is there anything I'm missing? Attaching a screenshot of how the tests ran, please give your feedback on the same. |
|
Others should tell whether they find it useful before you do more work on it, but I think you should at least merge I'm not sure why the tests are failing at the moment. |
…onstruct a EachReplaceNAWithFunctionResult
|
@nalimilan , Can you check paulvictor@365f1a3, if that's what you meant? I can provide a squashed commit later if the code makes sense. |
|
Yeah, something like that, but as I said I'll let other comment. |
|
Thanks @nalimilan , will wait too... |

Create another type which can replace with results of evaluating a function, optionally providing the data array itself as an argument. Use case: Replace with samples drawn from the distribution of non NA values.