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


Python SparseList.to_array方法代碼示例

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


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

示例1: test_append_zero

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_append_zero(self):
        arr = self.zero_data
        splist = SparseList(fill_value=0)
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        sparr = splist.to_array()
        assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
開發者ID:Acanthostega,項目名稱:pandas,代碼行數:11,代碼來源:test_list.py

示例2: test_append_na

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_append_na(self):
        arr = self.na_data
        splist = SparseList()
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        sparr = splist.to_array()
        assert_sp_array_equal(sparr, SparseArray(arr))
開發者ID:Acanthostega,項目名稱:pandas,代碼行數:11,代碼來源:test_list.py

示例3: test_append_na

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_append_na(self):
        with tm.assert_produces_warning(FutureWarning):
            arr = self.na_data
            splist = SparseList()
            splist.append(arr[:5])
            splist.append(arr[5])
            splist.append(arr[6:])

            sparr = splist.to_array()
            tm.assert_sp_array_equal(sparr, SparseArray(arr))
開發者ID:RogerThomas,項目名稱:pandas,代碼行數:12,代碼來源:test_list.py

示例4: test_append_zero

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_append_zero(self):
        with tm.assert_produces_warning(FutureWarning):
            arr = self.zero_data
            splist = SparseList(fill_value=0)
            splist.append(arr[:5])
            splist.append(arr[5])
            splist.append(arr[6:])

            sparr = splist.to_array()
            tm.assert_sp_array_equal(sparr, SparseArray(arr, fill_value=0))
開發者ID:DGrady,項目名稱:pandas,代碼行數:12,代碼來源:test_list.py

示例5: test_append_zero

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_append_zero(self):
        with tm.assert_produces_warning(FutureWarning):
            arr = self.zero_data
            splist = SparseList(fill_value=0)
            splist.append(arr[:5])
            splist.append(arr[5])
            splist.append(arr[6:])

            # list always produces int64, but SA constructor
            # is platform dtype aware
            sparr = splist.to_array()
            exp = SparseArray(arr, fill_value=0)
            tm.assert_sp_array_equal(sparr, exp, check_dtype=False)
開發者ID:RogerThomas,項目名稱:pandas,代碼行數:15,代碼來源:test_list.py

示例6: test_consolidate

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_consolidate(self):
        arr = self.na_data
        exp_sparr = SparseArray(arr)

        splist = SparseList()
        splist.append(arr[:5])
        splist.append(arr[5])
        splist.append(arr[6:])

        consol = splist.consolidate(inplace=False)
        self.assertEqual(consol.nchunks, 1)
        self.assertEqual(splist.nchunks, 3)
        assert_sp_array_equal(consol.to_array(), exp_sparr)

        splist.consolidate()
        self.assertEqual(splist.nchunks, 1)
        assert_sp_array_equal(splist.to_array(), exp_sparr)
開發者ID:Acanthostega,項目名稱:pandas,代碼行數:19,代碼來源:test_list.py

示例7: test_consolidate

# 需要導入模塊: from pandas.sparse.api import SparseList [as 別名]
# 或者: from pandas.sparse.api.SparseList import to_array [as 別名]
    def test_consolidate(self):
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            arr = self.na_data
            exp_sparr = SparseArray(arr)

            splist = SparseList()
            splist.append(arr[:5])
            splist.append(arr[5])
            splist.append(arr[6:])

            consol = splist.consolidate(inplace=False)
            self.assertEqual(consol.nchunks, 1)
            self.assertEqual(splist.nchunks, 3)
            tm.assert_sp_array_equal(consol.to_array(), exp_sparr)

            splist.consolidate()
            self.assertEqual(splist.nchunks, 1)
            tm.assert_sp_array_equal(splist.to_array(), exp_sparr)
開發者ID:RogerThomas,項目名稱:pandas,代碼行數:21,代碼來源:test_list.py


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