Python pandas.util.testing._make_skipna_wrapper() Examples
The following are 5
code examples of pandas.util.testing._make_skipna_wrapper().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.util.testing
, or try the search function
.
Example #1
Source File: test_panel.py From recruit with Apache License 2.0 | 5 votes |
def _check_stat_op(self, name, alternative, obj=None, has_skipna=True, skipna_alternative=None): if obj is None: obj = self.panel # # set some NAs # obj.loc[5:10] = np.nan # obj.loc[15:20, -2:] = np.nan f = getattr(obj, name) if has_skipna: skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative) def wrapper(x): return alternative(np.asarray(x)) for i in range(obj.ndim): result = f(axis=i, skipna=False) assert_frame_equal(result, obj.apply(wrapper, axis=i)) else: skipna_wrapper = alternative wrapper = alternative for i in range(obj.ndim): result = f(axis=i) if name in ['sum', 'prod']: assert_frame_equal(result, obj.apply(skipna_wrapper, axis=i)) pytest.raises(Exception, f, axis=obj.ndim) # Unimplemented numeric_only parameter. if 'numeric_only' in signature(f).args: with pytest.raises(NotImplementedError, match=name): f(numeric_only=True)
Example #2
Source File: test_panel.py From vnpy_crypto with MIT License | 5 votes |
def _check_stat_op(self, name, alternative, obj=None, has_skipna=True, skipna_alternative=None): if obj is None: obj = self.panel # # set some NAs # obj.loc[5:10] = np.nan # obj.loc[15:20, -2:] = np.nan f = getattr(obj, name) if has_skipna: skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative) def wrapper(x): return alternative(np.asarray(x)) for i in range(obj.ndim): result = f(axis=i, skipna=False) assert_frame_equal(result, obj.apply(wrapper, axis=i)) else: skipna_wrapper = alternative wrapper = alternative for i in range(obj.ndim): result = f(axis=i) if name in ['sum', 'prod']: assert_frame_equal(result, obj.apply(skipna_wrapper, axis=i)) pytest.raises(Exception, f, axis=obj.ndim) # Unimplemented numeric_only parameter. if 'numeric_only' in signature(f).args: tm.assert_raises_regex(NotImplementedError, name, f, numeric_only=True)
Example #3
Source File: test_panel.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def _check_stat_op(self, name, alternative, obj=None, has_skipna=True, skipna_alternative=None): if obj is None: obj = self.panel # # set some NAs # obj.loc[5:10] = np.nan # obj.loc[15:20, -2:] = np.nan f = getattr(obj, name) if has_skipna: skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative) def wrapper(x): return alternative(np.asarray(x)) for i in range(obj.ndim): result = f(axis=i, skipna=False) assert_frame_equal(result, obj.apply(wrapper, axis=i)) else: skipna_wrapper = alternative wrapper = alternative for i in range(obj.ndim): result = f(axis=i) if name in ['sum', 'prod']: assert_frame_equal(result, obj.apply(skipna_wrapper, axis=i)) pytest.raises(Exception, f, axis=obj.ndim) # Unimplemented numeric_only parameter. if 'numeric_only' in signature(f).args: with pytest.raises(NotImplementedError, match=name): f(numeric_only=True)
Example #4
Source File: test_panel.py From coffeegrindsize with MIT License | 5 votes |
def _check_stat_op(self, name, alternative, obj=None, has_skipna=True, skipna_alternative=None): if obj is None: obj = self.panel # # set some NAs # obj.loc[5:10] = np.nan # obj.loc[15:20, -2:] = np.nan f = getattr(obj, name) if has_skipna: skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative) def wrapper(x): return alternative(np.asarray(x)) for i in range(obj.ndim): result = f(axis=i, skipna=False) assert_frame_equal(result, obj.apply(wrapper, axis=i)) else: skipna_wrapper = alternative wrapper = alternative for i in range(obj.ndim): result = f(axis=i) if name in ['sum', 'prod']: assert_frame_equal(result, obj.apply(skipna_wrapper, axis=i)) pytest.raises(Exception, f, axis=obj.ndim) # Unimplemented numeric_only parameter. if 'numeric_only' in signature(f).args: with pytest.raises(NotImplementedError, match=name): f(numeric_only=True)
Example #5
Source File: test_panel.py From twitter-stock-recommendation with MIT License | 5 votes |
def _check_stat_op(self, name, alternative, obj=None, has_skipna=True, skipna_alternative=None): if obj is None: obj = self.panel # # set some NAs # obj.loc[5:10] = np.nan # obj.loc[15:20, -2:] = np.nan f = getattr(obj, name) if has_skipna: skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative) def wrapper(x): return alternative(np.asarray(x)) for i in range(obj.ndim): result = f(axis=i, skipna=False) assert_frame_equal(result, obj.apply(wrapper, axis=i)) else: skipna_wrapper = alternative wrapper = alternative for i in range(obj.ndim): result = f(axis=i) if name in ['sum', 'prod']: assert_frame_equal(result, obj.apply(skipna_wrapper, axis=i)) pytest.raises(Exception, f, axis=obj.ndim) # Unimplemented numeric_only parameter. if 'numeric_only' in signature(f).args: tm.assert_raises_regex(NotImplementedError, name, f, numeric_only=True)