-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Min max sparse #41159
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
Merged
Merged
Min max sparse #41159
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b1fb854
Updated qcut for Float64DType
taytzehao 7af63a2
Fixes from pre-commit [automated commit]
taytzehao c4259aa
Added test and documentation for qcut Float64DType support
taytzehao 043ae70
Merge branch 'master' of github.com:pandas-dev/pandas
taytzehao 48f21c6
Merge branch 'master' of https://github.com/taytzehao/pandas
taytzehao 29fddab
Updated qcut test formatting
taytzehao e489742
Merge branch 'master' of github.com:pandas-dev/pandas
taytzehao fd75ac5
Merge branch 'master' of github.com:pandas-dev/pandas into min_max_sp…
taytzehao e0f4253
Update sparse array minmax method
taytzehao 7b39607
Update sparse array minmax method 2
taytzehao 3b22ab2
Update sparse array minmax method 3
taytzehao 02d7f32
Update sparse array minmax method 4
taytzehao c6fe7e2
Update sparse array minmax method 5
taytzehao dddb6f6
Update sparse array minmax method 6
taytzehao 9c03b52
Update sparse array minmax method 6
taytzehao 227c282
Update sparse array minmax method 7
taytzehao 5dabba3
Update sparse array minmax method 8
taytzehao 85a99b4
Added test case and function to support NaN
taytzehao 0e6a384
Resolve precommit issue
taytzehao dc7b704
Merge branch 'master' of github.com:pandas-dev/pandas into min_max_sp…
taytzehao 10c40e5
Resolve precommit issue rst precommit issue resolved
taytzehao 13545b4
Add test coverage percentage
taytzehao ff83373
Updated what's new and SparseArray minmax logic
taytzehao 9e5fe39
Merge branch 'master' of github.com:pandas-dev/pandas into min_max_sp…
taytzehao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1392,6 +1392,30 @@ def mean(self, axis=0, *args, **kwargs): | |
nsparse = self.sp_index.ngaps | ||
return (sp_sum + self.fill_value * nsparse) / (ct + nsparse) | ||
|
||
def max(self, axis=0, *args, **kwargs): | ||
nv.validate_max(args, kwargs) | ||
|
||
if self.sp_index.ngaps > 0 and np.all(self._valid_sp_values < 0): | ||
|
||
if self.size > 0 and self._valid_sp_values.size == 0: | ||
return np.nan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldnt self.fill_value be relevant here? |
||
|
||
return 0 | ||
else: | ||
return np.amax(self._valid_sp_values, axis) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any particular reason for np.amax instead of np.max? |
||
|
||
def min(self, axis=0, *args, **kwargs): | ||
nv.validate_min(args, kwargs) | ||
|
||
if self.sp_index.ngaps > 0 and np.all(self._valid_sp_values > 0): | ||
|
||
if self.size > 0 and self._valid_sp_values.size == 0: | ||
return np.nan | ||
|
||
return 0 | ||
else: | ||
return np.amin(self._valid_sp_values, axis) | ||
|
||
# ------------------------------------------------------------------------ | ||
# Ufuncs | ||
# ------------------------------------------------------------------------ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: "Implemented :meth:`SparseArray.min` and :meth:`SparseArray.max` (:issue:`40921`)"