Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dimension-aware skipmissing #27818

Closed
wants to merge 2 commits into from

Conversation

stillyslalom
Copy link
Contributor

I added a method skipmissing(v, dims) = mapslices(skipmissing, v, dims) which allows compact notation for skipmissing over multidimensional arrays. Can be composed with basic stats functions to provide functionality similar to Matlab & Numpy's nanmean(array, dim), etc:

julia> mean.(skipmissing([1 missing; 3 4], 1))
1×2 Array{Float64,2}:
 2.0  4.0

This generates lots of views & iterators, so it's not the most performant, but it's a decent start. ref

Allows compact notation for `skipmissing` over multidimensional arrays. Can be composed with basic stats functions to provide functionality similar to Matlab & Numpy's `nanmean(array, dim)`, etc:
```
julia> mean.(skipmissing([1 missing; 3 4], 1))
1×2 Array{Float64,2}:
 2.0  4.0
```
@nalimilan
Copy link
Member

Thanks. Actually, I think we'll need a more complex implementation where you will call sum(x; dims=...) directly on the SkipMissing object. That would be more consistent with the pattern according to which dims is passed to the reduction function, it would be more natural than returning an array of SkipMissing objects, and more importantly maybe it would be more efficient.

I've already a branch where all of this mostly works, but I need to sort out some details.

@nalimilan nalimilan added the missing data Base.missing and related functionality label Jun 27, 2018
@stillyslalom stillyslalom deleted the patch-4 branch April 4, 2019 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing data Base.missing and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants