-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH-19629: Adding numpy nansun/nanmean, etc etc to _cython_table #19670
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
Changes from 8 commits
0d39286
47936c7
d2671e6
29ccb18
b702747
130f767
0e4657a
64c0d93
fdaeaf9
cabb307
0c5a2ae
7157161
93e332d
8c2a5dd
5326d56
bdd2917
528e12b
e88ac10
40e4dff
c9ddaff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1005,6 +1005,39 @@ def prng(self): | |
return np.random.RandomState(1234) | ||
|
||
|
||
class TestNumpyNaNFunctions(object): | ||
|
||
# xref GH 19629 | ||
def setup_method(self, method): | ||
self.test_series = pd.Series([1, 2, 3, 4, 5, 6]) | ||
self.test_df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) | ||
|
||
def compare_method_output(self, data, method, nan_method): | ||
tm.assert_almost_equal(data.agg(method), | ||
data.agg(nan_method), | ||
check_exact=True) | ||
|
||
@pytest.mark.parametrize("standard, nan_method", [ | ||
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. u can parametrize over df and series (or make into fixtures) then can inline the compare function 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. I'm not sure on a good way to handle the np compat tests if we took this approach, I'd be open to suggestions though 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.
|
||
(np.sum, np.nansum), | ||
(np.mean, np.nanmean), | ||
(np.std, np.nanstd), | ||
(np.var, np.nanvar), | ||
(np.median, np.nanmedian), | ||
(np.max, np.nanmax), | ||
(np.min, np.nanmin), | ||
(np.cumprod, np.nancumprod), | ||
(np.cumsum, np.nancumsum) | ||
]) | ||
def test_np_nan_functions(self, standard, nan_method): | ||
self.compare_method_output(self.test_series, standard, nan_method) | ||
self.compare_method_output(self.test_df, standard, nan_method) | ||
|
||
@td.skip_if_no("numpy", min_version="1.10.0") | ||
def test_np_nanprod(self): | ||
self.compare_method_output(self.test_series, np.prod, np.nanprod) | ||
self.compare_method_output(self.test_df, np.prod, np.nanprod) | ||
|
||
|
||
def test_use_bottleneck(): | ||
|
||
if nanops._BOTTLENECK_INSTALLED: | ||
|
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.
this can be a single function that is parameterized over all of the methods
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.
Sure, will do this soon - could you help with why the build is failing?
From looking at CircleCI it seems like it's not recognizing that np.nanprod is valid, do I need to remove the nanprod case for compat or something? Sorry if I'm being dense here.
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.
you might need to skip for older versions of numpy
not sure when certain ones were added