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


Python Panel.from_dict方法代码示例

本文整理汇总了Python中pandas.Panel.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Panel.from_dict方法的具体用法?Python Panel.from_dict怎么用?Python Panel.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.Panel的用法示例。


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

示例1: test_stack_sparse_frame

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_stack_sparse_frame(self, float_frame, float_frame_int_kind,
                                float_frame_fill0, float_frame_fill2):
        def _check(frame):
            dense_frame = frame.to_dense()  # noqa

            wp = Panel.from_dict({'foo': frame})
            from_dense_lp = wp.to_frame()

            from_sparse_lp = spf.stack_sparse_frame(frame)

            tm.assert_numpy_array_equal(from_dense_lp.values,
                                        from_sparse_lp.values)

        _check(float_frame)
        _check(float_frame_int_kind)

        # for now
        pytest.raises(Exception, _check, float_frame_fill0)
        pytest.raises(Exception, _check, float_frame_fill2) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_frame.py

示例2: test_stack_sparse_frame

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_stack_sparse_frame(self):
        with catch_warnings(record=True):

            def _check(frame):
                dense_frame = frame.to_dense()  # noqa

                wp = Panel.from_dict({'foo': frame})
                from_dense_lp = wp.to_frame()

                from_sparse_lp = spf.stack_sparse_frame(frame)

                tm.assert_numpy_array_equal(from_dense_lp.values,
                                            from_sparse_lp.values)

            _check(self.frame)
            _check(self.iframe)

            # for now
            pytest.raises(Exception, _check, self.zframe)
            pytest.raises(Exception, _check, self.fill_frame) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:test_frame.py

示例3: test_stack_sparse_frame

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_stack_sparse_frame(self):
        def _check(frame):
            dense_frame = frame.to_dense()

            wp = Panel.from_dict({'foo': frame})
            from_dense_lp = wp.to_frame()

            from_sparse_lp = spf.stack_sparse_frame(frame)

            self.assert_(np.array_equal(from_dense_lp.values,
                                        from_sparse_lp.values))

        _check(self.frame)
        _check(self.iframe)

        # for now
        self.assertRaises(Exception, _check, self.zframe)
        self.assertRaises(Exception, _check, self.fill_frame) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:test_sparse.py

示例4: test_from_dict

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_from_dict(self):
        fd = SparsePanel.from_dict(self.data_dict)
        assert_sp_panel_equal(fd, self.panel) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:test_sparse.py

示例5: test_dense_to_sparse

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_dense_to_sparse(self):
        wp = Panel.from_dict(self.data_dict)
        dwp = wp.to_sparse()
        tm.assert_isinstance(dwp['ItemA']['A'], SparseSeries) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:test_sparse.py

示例6: test_to_dense

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_to_dense(self):
        dwp = self.panel.to_dense()
        dwp2 = Panel.from_dict(self.data_dict)
        assert_panel_equal(dwp, dwp2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:test_sparse.py

示例7: testFamaMacBethRolling

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def testFamaMacBethRolling(self):
        # self.checkFamaMacBethExtended('rolling', self.panel_x, self.panel_y,
        #                               nw_lags_beta=2)

        # df = DataFrame(np.random.randn(50, 10))
        x = dict((k, DataFrame(np.random.randn(50, 10))) for k in 'abcdefg')
        x = Panel.from_dict(x)
        y = (DataFrame(np.random.randn(50, 10)) +
             DataFrame(0.01 * np.random.randn(50, 10)))
        self.checkFamaMacBethExtended('rolling', x, y, nw_lags_beta=2)
        self.checkFamaMacBethExtended('expanding', x, y, nw_lags_beta=2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:test_fama_macbeth.py

示例8: test_merge_nosort

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_merge_nosort(self):
        # #2098, anything to do?

        from datetime import datetime

        d = {"var1": np.random.randint(0, 10, size=10),
             "var2": np.random.randint(0, 10, size=10),
             "var3": [datetime(2012, 1, 12), datetime(2011, 2, 4),
                      datetime(
                      2010, 2, 3), datetime(2012, 1, 12),
                      datetime(
                      2011, 2, 4), datetime(2012, 4, 3),
                      datetime(
                      2012, 3, 4), datetime(2008, 5, 1),
                      datetime(2010, 2, 3), datetime(2012, 2, 3)]}
        df = DataFrame.from_dict(d)
        var3 = df.var3.unique()
        var3.sort()
        new = DataFrame.from_dict({"var3": var3,
                                   "var8": np.random.random(7)})

        result = df.merge(new, on="var3", sort=False)
        exp = merge(df, new, on='var3', sort=False)
        assert_frame_equal(result, exp)

        self.assert_((df.var3.unique() == result.var3.unique()).all()) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:28,代码来源:test_merge.py

示例9: test_panel_join_many

# 需要导入模块: from pandas import Panel [as 别名]
# 或者: from pandas.Panel import from_dict [as 别名]
def test_panel_join_many(self):
        tm.K = 10
        panel = tm.makePanel()
        tm.K = 4

        panels = [panel.ix[:2], panel.ix[2:6], panel.ix[6:]]

        joined = panels[0].join(panels[1:])
        tm.assert_panel_equal(joined, panel)

        panels = [panel.ix[:2, :-5], panel.ix[2:6, 2:], panel.ix[6:, 5:-7]]

        data_dict = {}
        for p in panels:
            data_dict.update(compat.iteritems(p))

        joined = panels[0].join(panels[1:], how='inner')
        expected = Panel.from_dict(data_dict, intersect=True)
        tm.assert_panel_equal(joined, expected)

        joined = panels[0].join(panels[1:], how='outer')
        expected = Panel.from_dict(data_dict, intersect=False)
        tm.assert_panel_equal(joined, expected)

        # edge cases
        self.assertRaises(ValueError, panels[0].join, panels[1:],
                          how='outer', lsuffix='foo', rsuffix='bar')
        self.assertRaises(ValueError, panels[0].join, panels[1:],
                          how='right') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:test_merge.py


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