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


Python testing.makePeriodPanel方法代碼示例

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


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

示例1: test_tshift

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makePeriodPanel [as 別名]
def test_tshift(self):
        # PeriodIndex
        ps = tm.makePeriodPanel()
        shifted = ps.tshift(1)
        unshifted = shifted.tshift(-1)

        assert_panel_equal(unshifted, ps)

        shifted2 = ps.tshift(freq='B')
        assert_panel_equal(shifted, shifted2)

        shifted3 = ps.tshift(freq=BDay())
        assert_panel_equal(shifted, shifted3)

        with pytest.raises(ValueError, match='does not match'):
            ps.tshift(freq='M')

        # DatetimeIndex
        panel = make_test_panel()
        shifted = panel.tshift(1)
        unshifted = shifted.tshift(-1)

        assert_panel_equal(panel, unshifted)

        shifted2 = panel.tshift(freq=panel.major_axis.freq)
        assert_panel_equal(shifted, shifted2)

        inferred_ts = Panel(panel.values, items=panel.items,
                            major_axis=Index(np.asarray(panel.major_axis)),
                            minor_axis=panel.minor_axis)
        shifted = inferred_ts.tshift(1)
        unshifted = shifted.tshift(-1)
        assert_panel_equal(shifted, panel.tshift(1))
        assert_panel_equal(unshifted, inferred_ts)

        no_freq = panel.iloc[:, [0, 5, 7], :]
        pytest.raises(ValueError, no_freq.tshift) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:39,代碼來源:test_panel.py

示例2: test_isna_isnull

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makePeriodPanel [as 別名]
def test_isna_isnull(self, isna_f):
        assert not isna_f(1.)
        assert isna_f(None)
        assert isna_f(np.NaN)
        assert float('nan')
        assert not isna_f(np.inf)
        assert not isna_f(-np.inf)

        # series
        for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
                  tm.makeObjectSeries(), tm.makeTimeSeries(),
                  tm.makePeriodSeries()]:
            assert isinstance(isna_f(s), Series)

        # frame
        for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
                   tm.makeMixedDataFrame()]:
            result = isna_f(df)
            expected = df.apply(isna_f)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            simplefilter("ignore", FutureWarning)
            for p in [tm.makePanel(), tm.makePeriodPanel(),
                      tm.add_nans(tm.makePanel())]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:31,代碼來源:test_missing.py

示例3: test_tshift

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makePeriodPanel [as 別名]
def test_tshift(self):
        # PeriodIndex
        with catch_warnings(record=True):
            ps = tm.makePeriodPanel()
            shifted = ps.tshift(1)
            unshifted = shifted.tshift(-1)

            assert_panel_equal(unshifted, ps)

            shifted2 = ps.tshift(freq='B')
            assert_panel_equal(shifted, shifted2)

            shifted3 = ps.tshift(freq=BDay())
            assert_panel_equal(shifted, shifted3)

            tm.assert_raises_regex(ValueError, 'does not match',
                                   ps.tshift, freq='M')

            # DatetimeIndex
            panel = make_test_panel()
            shifted = panel.tshift(1)
            unshifted = shifted.tshift(-1)

            assert_panel_equal(panel, unshifted)

            shifted2 = panel.tshift(freq=panel.major_axis.freq)
            assert_panel_equal(shifted, shifted2)

            inferred_ts = Panel(panel.values, items=panel.items,
                                major_axis=Index(np.asarray(panel.major_axis)),
                                minor_axis=panel.minor_axis)
            shifted = inferred_ts.tshift(1)
            unshifted = shifted.tshift(-1)
            assert_panel_equal(shifted, panel.tshift(1))
            assert_panel_equal(unshifted, inferred_ts)

            no_freq = panel.iloc[:, [0, 5, 7], :]
            pytest.raises(ValueError, no_freq.tshift) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:40,代碼來源:test_panel.py

示例4: test_isna_isnull

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makePeriodPanel [as 別名]
def test_isna_isnull(self, isna_f):
        assert not isna_f(1.)
        assert isna_f(None)
        assert isna_f(np.NaN)
        assert float('nan')
        assert not isna_f(np.inf)
        assert not isna_f(-np.inf)

        # series
        for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
                  tm.makeObjectSeries(), tm.makeTimeSeries(),
                  tm.makePeriodSeries()]:
            assert isinstance(isna_f(s), Series)

        # frame
        for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
                   tm.makeMixedDataFrame()]:
            result = isna_f(df)
            expected = df.apply(isna_f)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            for p in [tm.makePanel(), tm.makePeriodPanel(),
                      tm.add_nans(tm.makePanel())]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel_equal(result, expected) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:30,代碼來源:test_missing.py

示例5: test_isna_isnull

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makePeriodPanel [as 別名]
def test_isna_isnull(self, isna_f):
        assert not isna_f(1.)
        assert isna_f(None)
        assert isna_f(np.NaN)
        assert float('nan')
        assert not isna_f(np.inf)
        assert not isna_f(-np.inf)

        # series
        for s in [tm.makeFloatSeries(), tm.makeStringSeries(),
                  tm.makeObjectSeries(), tm.makeTimeSeries(),
                  tm.makePeriodSeries()]:
            assert isinstance(isna_f(s), Series)

        # frame
        for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(),
                   tm.makeMixedDataFrame()]:
            result = isna_f(df)
            expected = df.apply(isna_f)
            tm.assert_frame_equal(result, expected)

        # panel
        with catch_warnings(record=True):
            for p in [tm.makePanel(), tm.makePeriodPanel(),
                      tm.add_nans(tm.makePanel())]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel_equal(result, expected)

        # panel 4d
        with catch_warnings(record=True):
            for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]:
                result = isna_f(p)
                expected = p.apply(isna_f)
                tm.assert_panel4d_equal(result, expected) 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:37,代碼來源:test_missing.py


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