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


Python offsets.Micro方法代碼示例

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


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

示例1: test_Microsecond

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_Microsecond():
    assert_offset_equal(Micro(),
                        datetime(2010, 1, 1),
                        datetime(2010, 1, 1, 0, 0, 0, 1))
    assert_offset_equal(Micro(-1),
                        datetime(2010, 1, 1, 0, 0, 0, 1),
                        datetime(2010, 1, 1))

    assert_offset_equal(2 * Micro(),
                        datetime(2010, 1, 1),
                        datetime(2010, 1, 1, 0, 0, 0, 2))
    assert_offset_equal(-1 * Micro(),
                        datetime(2010, 1, 1, 0, 0, 0, 1),
                        datetime(2010, 1, 1))

    assert Micro(3) + Micro(2) == Micro(5)
    assert Micro(3) - Micro(2) == Micro() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_ticks.py

示例2: test_Nanosecond

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:test_ticks.py

示例3: test_is_superperiod_subperiod

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_is_superperiod_subperiod():

    # input validation
    assert not (frequencies.is_superperiod(offsets.YearEnd(), None))
    assert not (frequencies.is_subperiod(offsets.MonthEnd(), None))
    assert not (frequencies.is_superperiod(None, offsets.YearEnd()))
    assert not (frequencies.is_subperiod(None, offsets.MonthEnd()))
    assert not (frequencies.is_superperiod(None, None))
    assert not (frequencies.is_subperiod(None, None))

    assert (frequencies.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (frequencies.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (frequencies.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (frequencies.is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (frequencies.is_superperiod(offsets.Second(), offsets.Milli()))
    assert (frequencies.is_subperiod(offsets.Milli(), offsets.Second()))

    assert (frequencies.is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (frequencies.is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro())) 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:26,代碼來源:test_frequencies.py

示例4: test_resolution

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_resolution(self):
        def _assert_less(ts1, ts2):
            val1 = self.dtc.convert(ts1, None, None)
            val2 = self.dtc.convert(ts2, None, None)
            if not val1 < val2:
                raise AssertionError('{0} is not less than {1}.'.format(val1,
                                                                        val2))

        # Matplotlib's time representation using floats cannot distinguish
        # intervals smaller than ~10 microsecond in the common range of years.
        ts = Timestamp('2012-1-1')
        _assert_less(ts, ts + Second())
        _assert_less(ts, ts + Milli())
        _assert_less(ts, ts + Micro(50)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:16,代碼來源:test_converter.py

示例5: test_to_offset_pd_timedelta

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_to_offset_pd_timedelta(self):
        # Tests for #9064
        td = Timedelta(days=1, seconds=1)
        result = frequencies.to_offset(td)
        expected = offsets.Second(86401)
        assert (expected == result)

        td = Timedelta(days=-1, seconds=1)
        result = frequencies.to_offset(td)
        expected = offsets.Second(-86399)
        assert (expected == result)

        td = Timedelta(hours=1, minutes=10)
        result = frequencies.to_offset(td)
        expected = offsets.Minute(70)
        assert (expected == result)

        td = Timedelta(hours=1, minutes=-10)
        result = frequencies.to_offset(td)
        expected = offsets.Minute(50)
        assert (expected == result)

        td = Timedelta(weeks=1)
        result = frequencies.to_offset(td)
        expected = offsets.Day(7)
        assert (expected == result)

        td1 = Timedelta(hours=1)
        result1 = frequencies.to_offset(td1)
        result2 = frequencies.to_offset('60min')
        assert (result1 == result2)

        td = Timedelta(microseconds=1)
        result = frequencies.to_offset(td)
        expected = offsets.Micro(1)
        assert (expected == result)

        td = Timedelta(microseconds=0)
        pytest.raises(ValueError, lambda: frequencies.to_offset(td)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:41,代碼來源:test_frequencies.py

示例6: test_rule_aliases

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_rule_aliases():
    rule = frequencies.to_offset('10us')
    assert rule == offsets.Micro(10) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_frequencies.py

示例7: test_to_offset_multiple

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Micro [as 別名]
def test_to_offset_multiple():
    freqstr = '2h30min'
    freqstr2 = '2h 30min'

    result = to_offset(freqstr)
    assert(result == to_offset(freqstr2))
    expected = offsets.Minute(150)
    assert(result == expected)

    freqstr = '2h30min15s'
    result = to_offset(freqstr)
    expected = offsets.Second(150 * 60 + 15)
    assert(result == expected)

    freqstr = '2h 60min'
    result = to_offset(freqstr)
    expected = offsets.Hour(3)
    assert(result == expected)

    freqstr = '15l500u'
    result = to_offset(freqstr)
    expected = offsets.Micro(15500)
    assert(result == expected)

    freqstr = '10s75L'
    result = to_offset(freqstr)
    expected = offsets.Milli(10075)
    assert(result == expected)

    if not _np_version_under1p7:
        freqstr = '2800N'
        result = to_offset(freqstr)
        expected = offsets.Nano(2800)
        assert(result == expected)

    # malformed
    try:
        to_offset('2h20m')
    except ValueError:
        pass
    else:
        assert(False) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:44,代碼來源:test_frequencies.py


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