Python pandas.core.nanops.nansum() Examples
The following are 24
code examples of pandas.core.nanops.nansum().
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.core.nanops
, or try the search function
.
Example #1
Source File: test_reductions.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_sum_inf(self): s = Series(np.random.randn(10)) s2 = s.copy() s[5:8] = np.inf s2[5:8] = np.nan assert np.isinf(s.sum()) arr = np.random.randn(100, 100).astype('f4') arr[:, 2] = np.inf with pd.option_context("mode.use_inf_as_na", True): tm.assert_almost_equal(s.sum(), s2.sum()) res = nanops.nansum(arr, axis=1) assert np.isinf(res).all()
Example #2
Source File: test_analytics.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_sum_inf(self): s = Series(np.random.randn(10)) s2 = s.copy() s[5:8] = np.inf s2[5:8] = np.nan assert np.isinf(s.sum()) arr = np.random.randn(100, 100).astype('f4') arr[:, 2] = np.inf with pd.option_context("mode.use_inf_as_na", True): assert_almost_equal(s.sum(), s2.sum()) res = nanops.nansum(arr, axis=1) assert np.isinf(res).all()
Example #3
Source File: test_apply.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_apply(frame): applied = frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(frame.values)) # agg / broadcast with tm.assert_produces_warning(FutureWarning): broadcasted = frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) with tm.assert_produces_warning(FutureWarning): exp = frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) applied = frame.apply(np.sum) tm.assert_series_equal(applied, frame.to_dense().apply(nanops.nansum))
Example #4
Source File: test_apply.py From coffeegrindsize with MIT License | 6 votes |
def test_apply(frame): applied = frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(frame.values)) # agg / broadcast with tm.assert_produces_warning(FutureWarning): broadcasted = frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) with tm.assert_produces_warning(FutureWarning): exp = frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) applied = frame.apply(np.sum) tm.assert_series_equal(applied, frame.to_dense().apply(nanops.nansum).to_sparse())
Example #5
Source File: test_analytics.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_sum_inf(self): s = Series(np.random.randn(10)) s2 = s.copy() s[5:8] = np.inf s2[5:8] = np.nan assert np.isinf(s.sum()) arr = np.random.randn(100, 100).astype('f4') arr[:, 2] = np.inf with pd.option_context("mode.use_inf_as_na", True): assert_almost_equal(s.sum(), s2.sum()) res = nanops.nansum(arr, axis=1) assert np.isinf(res).all()
Example #6
Source File: test_frame.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_apply(self): applied = self.frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(self.frame.values)) applied = self.fill_frame.apply(np.sqrt) assert applied['A'].fill_value == np.sqrt(2) # agg / broadcast broadcasted = self.frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) exp = self.frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) assert self.empty.apply(np.sqrt) is self.empty from pandas.core import nanops applied = self.frame.apply(np.sum) tm.assert_series_equal(applied, self.frame.to_dense().apply(nanops.nansum))
Example #7
Source File: test_apply.py From recruit with Apache License 2.0 | 6 votes |
def test_apply(frame): applied = frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(frame.values)) # agg / broadcast with tm.assert_produces_warning(FutureWarning): broadcasted = frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) with tm.assert_produces_warning(FutureWarning): exp = frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) applied = frame.apply(np.sum) tm.assert_series_equal(applied, frame.to_dense().apply(nanops.nansum).to_sparse())
Example #8
Source File: test_apply.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_apply(frame): applied = frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(frame.values)) # agg / broadcast with tm.assert_produces_warning(FutureWarning): broadcasted = frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) with tm.assert_produces_warning(FutureWarning): exp = frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) applied = frame.apply(np.sum) tm.assert_series_equal(applied, frame.to_dense().apply(nanops.nansum).to_sparse())
Example #9
Source File: test_sparse.py From Computable with MIT License | 6 votes |
def test_apply(self): applied = self.frame.apply(np.sqrt) tm.assert_isinstance(applied, SparseDataFrame) assert_almost_equal(applied.values, np.sqrt(self.frame.values)) applied = self.fill_frame.apply(np.sqrt) self.assert_(applied['A'].fill_value == np.sqrt(2)) # agg / broadcast broadcasted = self.frame.apply(np.sum, broadcast=True) tm.assert_isinstance(broadcasted, SparseDataFrame) assert_frame_equal(broadcasted.to_dense(), self.frame.to_dense().apply(np.sum, broadcast=True)) self.assert_(self.empty.apply(np.sqrt) is self.empty) from pandas.core import nanops applied = self.frame.apply(np.sum) assert_series_equal(applied, self.frame.to_dense().apply(nanops.nansum))
Example #10
Source File: test_analytics.py From vnpy_crypto with MIT License | 6 votes |
def test_sum_inf(self): s = Series(np.random.randn(10)) s2 = s.copy() s[5:8] = np.inf s2[5:8] = np.nan assert np.isinf(s.sum()) arr = np.random.randn(100, 100).astype('f4') arr[:, 2] = np.inf with pd.option_context("mode.use_inf_as_na", True): assert_almost_equal(s.sum(), s2.sum()) res = nanops.nansum(arr, axis=1) assert np.isinf(res).all()
Example #11
Source File: test_apply.py From vnpy_crypto with MIT License | 6 votes |
def test_apply(frame): applied = frame.apply(np.sqrt) assert isinstance(applied, SparseDataFrame) tm.assert_almost_equal(applied.values, np.sqrt(frame.values)) # agg / broadcast with tm.assert_produces_warning(FutureWarning): broadcasted = frame.apply(np.sum, broadcast=True) assert isinstance(broadcasted, SparseDataFrame) with tm.assert_produces_warning(FutureWarning): exp = frame.to_dense().apply(np.sum, broadcast=True) tm.assert_frame_equal(broadcasted.to_dense(), exp) applied = frame.apply(np.sum) tm.assert_series_equal(applied, frame.to_dense().apply(nanops.nansum))
Example #12
Source File: test_reductions.py From recruit with Apache License 2.0 | 6 votes |
def test_sum_inf(self): s = Series(np.random.randn(10)) s2 = s.copy() s[5:8] = np.inf s2[5:8] = np.nan assert np.isinf(s.sum()) arr = np.random.randn(100, 100).astype('f4') arr[:, 2] = np.inf with pd.option_context("mode.use_inf_as_na", True): tm.assert_almost_equal(s.sum(), s2.sum()) res = nanops.nansum(arr, axis=1) assert np.isinf(res).all()
Example #13
Source File: test_analytics.py From vnpy_crypto with MIT License | 5 votes |
def test_nansum_buglet(self): s = Series([1.0, np.nan], index=[0, 1]) result = np.nansum(s) assert_almost_equal(result, 1)
Example #14
Source File: test_nanops.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_nansum(self): self.check_funs(nanops.nansum, np.sum, allow_str=False, allow_date=False, allow_tdelta=True, check_dtype=False, empty_targfunc=np.nansum)
Example #15
Source File: test_nanops.py From vnpy_crypto with MIT License | 5 votes |
def test_nansum(self): self.check_funs(nanops.nansum, np.sum, allow_str=False, allow_date=False, allow_tdelta=True, check_dtype=False, empty_targfunc=np.nansum)
Example #16
Source File: test_reductions.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_nansum_buglet(self): ser = Series([1.0, np.nan], index=[0, 1]) result = np.nansum(ser) tm.assert_almost_equal(result, 1)
Example #17
Source File: numpy_.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def sum(self, axis=None, dtype=None, out=None, keepdims=False, initial=None, skipna=True, min_count=0): nv.validate_sum((), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)) return nanops.nansum(self._ndarray, axis=axis, skipna=skipna, min_count=min_count)
Example #18
Source File: test_nanops.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_nansum(self): self.check_funs(nanops.nansum, np.sum, allow_str=False, allow_date=False, allow_tdelta=True, check_dtype=False)
Example #19
Source File: test_analytics.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_nansum_buglet(self): s = Series([1.0, np.nan], index=[0, 1]) result = np.nansum(s) assert_almost_equal(result, 1)
Example #20
Source File: numpy_.py From recruit with Apache License 2.0 | 5 votes |
def sum(self, axis=None, dtype=None, out=None, keepdims=False, initial=None, skipna=True, min_count=0): nv.validate_sum((), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)) return nanops.nansum(self._ndarray, axis=axis, skipna=skipna, min_count=min_count)
Example #21
Source File: test_reductions.py From recruit with Apache License 2.0 | 5 votes |
def test_nansum_buglet(self): ser = Series([1.0, np.nan], index=[0, 1]) result = np.nansum(ser) tm.assert_almost_equal(result, 1)
Example #22
Source File: test_nanops.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_nansum(self): self.check_funs(nanops.nansum, np.sum, allow_str=False, allow_date=False, allow_tdelta=True, check_dtype=False, empty_targfunc=np.nansum)
Example #23
Source File: test_analytics.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_nansum_buglet(self): s = Series([1.0, np.nan], index=[0, 1]) result = np.nansum(s) assert_almost_equal(result, 1)
Example #24
Source File: test_nanops.py From recruit with Apache License 2.0 | 5 votes |
def test_nansum(self): self.check_funs(nanops.nansum, np.sum, allow_str=False, allow_date=False, allow_tdelta=True, check_dtype=False, empty_targfunc=np.nansum)