当前位置: 首页>>代码示例>>Python>>正文


Python _sparse.BlockIndex类代码示例

本文整理汇总了Python中pandas._sparse.BlockIndex的典型用法代码示例。如果您正苦于以下问题:Python BlockIndex类的具体用法?Python BlockIndex怎么用?Python BlockIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BlockIndex类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check_case

        def _check_case(xloc, xlen, yloc, ylen, eloc, elen):
            xindex = BlockIndex(TEST_LENGTH, xloc, xlen)
            yindex = BlockIndex(TEST_LENGTH, yloc, ylen)

            xdindex = xindex.to_int_index()
            ydindex = yindex.to_int_index()

            x = np.arange(xindex.npoints) * 10. + 1
            y = np.arange(yindex.npoints) * 100. + 1

            xfill = 0
            yfill = 2

            result_block_vals, rb_index = sparse_op(
                x, xindex, xfill, y, yindex, yfill)
            result_int_vals, ri_index = sparse_op(x, xdindex, xfill,
                                                  y, ydindex, yfill)

            self.assert_(rb_index.to_int_index().equals(ri_index))
            assert_equal(result_block_vals, result_int_vals)

            # check versus Series...
            xseries = Series(x, xdindex.indices)
            xseries = xseries.reindex(np.arange(TEST_LENGTH)).fillna(xfill)

            yseries = Series(y, ydindex.indices)
            yseries = yseries.reindex(np.arange(TEST_LENGTH)).fillna(yfill)

            series_result = python_op(xseries, yseries)
            series_result = series_result.reindex(ri_index.indices)

            assert_equal(result_block_vals, series_result.values)
            assert_equal(result_int_vals, series_result.values)
开发者ID:Acanthostega,项目名称:pandas,代码行数:33,代码来源:test_libsparse.py

示例2: test_to_int_index

    def test_to_int_index(self):
        locs = [0, 10]
        lengths = [4, 6]
        exp_inds = [0, 1, 2, 3, 10, 11, 12, 13, 14, 15]

        block = BlockIndex(20, locs, lengths)
        dense = block.to_int_index()

        assert_equal(dense.indices, exp_inds)
开发者ID:Acanthostega,项目名称:pandas,代码行数:9,代码来源:test_libsparse.py

示例3: _check_case

    def _check_case(xloc, xlen, yloc, ylen, eloc, elen):
        xindex = BlockIndex(TEST_LENGTH, xloc, xlen)
        yindex = BlockIndex(TEST_LENGTH, yloc, ylen)
        expected = BlockIndex(TEST_LENGTH, eloc, elen)
        longer_index = BlockIndex(TEST_LENGTH + 1, yloc, ylen)

        _check_correct(xindex, yindex, expected)
        _check_correct(xindex.to_int_index(), yindex.to_int_index(), expected.to_int_index())

        _check_length_exc(xindex, longer_index)
        _check_length_exc(xindex.to_int_index(), longer_index.to_int_index())
开发者ID:hack-c,项目名称:pandas,代码行数:11,代码来源:test_libsparse.py

示例4: test_lookup

def test_lookup():
    def _check(index):
        assert index.lookup(0) == -1
        assert index.lookup(5) == 0
        assert index.lookup(7) == 2
        assert index.lookup(8) == -1
        assert index.lookup(9) == -1
        assert index.lookup(10) == -1
        assert index.lookup(11) == -1
        assert index.lookup(12) == 3
        assert index.lookup(17) == 8
        assert index.lookup(18) == -1

    bindex = BlockIndex(20, [5, 12], [3, 6])
    iindex = bindex.to_int_index()

    _check(bindex)
    _check(iindex)
开发者ID:hack-c,项目名称:pandas,代码行数:18,代码来源:test_libsparse.py

示例5: _check_case

        def _check_case(xloc, xlen, yloc, ylen, eloc, elen):
            xindex = BlockIndex(TEST_LENGTH, xloc, xlen)
            yindex = BlockIndex(TEST_LENGTH, yloc, ylen)

            xdindex = xindex.to_int_index()
            ydindex = yindex.to_int_index()

            x = np.arange(xindex.npoints) * 10. + 1
            y = np.arange(yindex.npoints) * 100. + 1

            result_block_vals, rb_index = sparse_op(x, xindex, y, yindex)
            result_int_vals, ri_index = sparse_op(x, xdindex, y, ydindex)

            self.assertTrue(rb_index.to_int_index().equals(ri_index))
            assert_equal(result_block_vals, result_int_vals)

            # check versus Series...
            xseries = Series(x, xdindex.indices)
            yseries = Series(y, ydindex.indices)
            series_result = python_op(xseries, yseries).valid()
            assert_equal(result_block_vals, series_result.values)
            assert_equal(result_int_vals, series_result.values)
开发者ID:Garrett-R,项目名称:pandas,代码行数:22,代码来源:test_libsparse.py

示例6: test_to_block_index

 def test_to_block_index(self):
     index = BlockIndex(10, [0, 5], [4, 5])
     self.assertIs(index.to_block_index(), index)
开发者ID:Acanthostega,项目名称:pandas,代码行数:3,代码来源:test_libsparse.py

示例7: test_equals

    def test_equals(self):
        index = BlockIndex(10, [0, 4], [2, 5])

        self.assert_(index.equals(index))
        self.assert_(not index.equals(BlockIndex(10, [0, 4], [2, 6])))
开发者ID:Acanthostega,项目名称:pandas,代码行数:5,代码来源:test_libsparse.py

示例8: test_equals

    def test_equals(self):
        index = BlockIndex(10, [0, 4], [2, 5])

        self.assertTrue(index.equals(index))
        self.assertFalse(index.equals(BlockIndex(10, [0, 4], [2, 6])))
开发者ID:Garrett-R,项目名称:pandas,代码行数:5,代码来源:test_libsparse.py


注:本文中的pandas._sparse.BlockIndex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。