Python scipy.sparse.value_counts() Examples
The following are 18
code examples of scipy.sparse.value_counts().
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
scipy.sparse
, or try the search function
.
Example #1
Source File: test_series.py From recruit with Apache License 2.0 | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #2
Source File: test_series.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #3
Source File: test_series.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #4
Source File: test_series.py From coffeegrindsize with MIT License | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #5
Source File: test_series.py From coffeegrindsize with MIT License | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #6
Source File: test_series.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #7
Source File: test_series.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #8
Source File: test_series.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #9
Source File: test_series.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #10
Source File: test_series.py From vnpy_crypto with MIT License | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #11
Source File: test_series.py From vnpy_crypto with MIT License | 6 votes |
def test_value_counts_dup(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] # numeric op may cause sp_values to include the same value as # fill_value dense = pd.Series(vals, name='xx') / 0. sparse = pd.SparseSeries(vals, name='xx') / 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) vals = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') * 0. sparse = pd.SparseSeries(vals, name='xx') * 0. tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #12
Source File: test_series.py From recruit with Apache License 2.0 | 6 votes |
def test_value_counts_int(self): vals = [1, 2, 0, 1, 2, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') # fill_value is np.nan, but should not be included in the result sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #13
Source File: test_series.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #14
Source File: test_series.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #15
Source File: test_series.py From coffeegrindsize with MIT License | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #16
Source File: test_series.py From vnpy_crypto with MIT License | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #17
Source File: test_series.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))
Example #18
Source File: test_series.py From recruit with Apache License 2.0 | 5 votes |
def test_value_counts(self): vals = [1, 2, nan, 0, nan, 1, 2, nan, nan, 1, 2, 0, 1, 1] dense = pd.Series(vals, name='xx') sparse = pd.SparseSeries(vals, name='xx') tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False)) sparse = pd.SparseSeries(vals, name='xx', fill_value=0) tm.assert_series_equal(sparse.value_counts(), dense.value_counts()) tm.assert_series_equal(sparse.value_counts(dropna=False), dense.value_counts(dropna=False))