当前位置: 首页>>代码示例>>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;未经允许,请勿转载。