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

Nan Changes #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions bolt/spark/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,21 @@ def mean(self, axis=None, keepdims=False):
"""
return self._stat(axis, name='mean', keepdims=keepdims)

def nanmean(self, axis=None, keepdims=False):
"""
Return the nanmean of the array over the given axis.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nanmean', keepdims=keepdims)

def var(self, axis=None, keepdims=False):
"""
Return the variance of the array over the given axis.
Expand All @@ -349,6 +364,21 @@ def var(self, axis=None, keepdims=False):
"""
return self._stat(axis, name='variance', keepdims=keepdims)

def nanvar(self, axis=None, keepdims=False):
"""
Return the variance of the array over the given axis ignoring NaNs.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nanvariance', keepdims=keepdims)

def std(self, axis=None, keepdims=False):
"""
Return the standard deviation of the array over the given axis.
Expand All @@ -364,6 +394,21 @@ def std(self, axis=None, keepdims=False):
"""
return self._stat(axis, name='stdev', keepdims=keepdims)

def nanstd(self, axis=None, keepdims=False):
"""
Return the standard deviation of the array over the given axis ignoring NaNs.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nanstdev', keepdims=keepdims)

def sum(self, axis=None, keepdims=False):
"""
Return the sum of the array over the given axis.
Expand All @@ -380,6 +425,21 @@ def sum(self, axis=None, keepdims=False):
from operator import add
return self._stat(axis, func=add, keepdims=keepdims)

def nansum(self, axis=None, keepdims=False):
"""
Return the sum of the array over the given axis ignoring NaNs.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nansum', keepdims=keepdims)

def max(self, axis=None, keepdims=False):
"""
Return the maximum of the array over the given axis.
Expand All @@ -396,6 +456,21 @@ def max(self, axis=None, keepdims=False):
from numpy import maximum
return self._stat(axis, func=maximum, keepdims=keepdims)

def nanmax(self, axis=None, keepdims=False):
"""
Return the maximum of the array over the given axis ignoring NaNs.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nanmax', keepdims=keepdims)

def min(self, axis=None, keepdims=False):
"""
Return the minimum of the array over the given axis.
Expand All @@ -412,6 +487,36 @@ def min(self, axis=None, keepdims=False):
from numpy import minimum
return self._stat(axis, func=minimum, keepdims=keepdims)

def nanmin(self, axis=None, keepdims=False):
"""
Return the minimum of the array over the given axis ignoring NaNs.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nanmin', keepdims=keepdims)

def nancount(self, axis=None, keepdims=False):
"""
Return the count of non NaN values.

Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes

keepdims : boolean, optional, default=False
Keep axis remaining after operation with size 1.
"""
return self._stat(axis, name='nancount', keepdims=keepdims)

def concatenate(self, arry, axis=0):
"""
Join this array with another array.
Expand Down
Loading