當前位置: 首頁>>代碼示例>>Python>>正文


Python sparse.value_counts方法代碼示例

本文整理匯總了Python中scipy.sparse.value_counts方法的典型用法代碼示例。如果您正苦於以下問題:Python sparse.value_counts方法的具體用法?Python sparse.value_counts怎麽用?Python sparse.value_counts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.sparse的用法示例。


在下文中一共展示了sparse.value_counts方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_value_counts_dup

# 需要導入模塊: from scipy import sparse [as 別名]
# 或者: from scipy.sparse import value_counts [as 別名]
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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:22,代碼來源:test_series.py

示例2: test_value_counts_int

# 需要導入模塊: from scipy import sparse [as 別名]
# 或者: from scipy.sparse import value_counts [as 別名]
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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_series.py

示例3: test_value_counts

# 需要導入模塊: from scipy import sparse [as 別名]
# 或者: from scipy.sparse import value_counts [as 別名]
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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:test_series.py


注:本文中的scipy.sparse.value_counts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。