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


Python testing.assert_attr_equal方法代碼示例

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


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

示例1: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self, sort):
        # GH14323: Difference of TimedeltaIndex should not preserve frequency

        index = timedelta_range("0 days", "5 days", freq="D")

        other = timedelta_range("1 days", "4 days", freq="D")
        expected = TimedeltaIndex(["0 days", "5 days"], freq=None)
        idx_diff = index.difference(other, sort)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = timedelta_range("2 days", "5 days", freq="D")
        idx_diff = index.difference(other, sort)
        expected = TimedeltaIndex(["0 days", "1 days"], freq=None)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_timedelta.py

示例2: test_difference_sort

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_sort(self, sort):

        index = pd.TimedeltaIndex(["5 days", "3 days", "2 days", "4 days",
                                   "1 days", "0 days"])

        other = timedelta_range("1 days", "4 days", freq="D")
        idx_diff = index.difference(other, sort)

        expected = TimedeltaIndex(["5 days", "0 days"], freq=None)

        if sort is None:
            expected = expected.sort_values()

        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = timedelta_range("2 days", "5 days", freq="D")
        idx_diff = index.difference(other, sort)
        expected = TimedeltaIndex(["1 days", "0 days"], freq=None)

        if sort is None:
            expected = expected.sort_values()

        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:test_timedelta.py

示例3: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self, sort):
        # GH14323: difference of Period MUST preserve frequency
        # but the ability to union results must be preserved

        index = period_range("20160920", "20160925", freq="D")

        other = period_range("20160921", "20160924", freq="D")
        expected = PeriodIndex(["20160920", "20160925"], freq='D')
        idx_diff = index.difference(other, sort)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = period_range("20160922", "20160925", freq="D")
        idx_diff = index.difference(other, sort)
        expected = PeriodIndex(["20160920", "20160921"], freq='D')
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_period.py

示例4: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self):
        # GH14323: Difference of TimedeltaIndex should not preserve frequency

        index = timedelta_range("0 days", "5 days", freq="D")

        other = timedelta_range("1 days", "4 days", freq="D")
        expected = TimedeltaIndex(["0 days", "5 days"], freq=None)
        idx_diff = index.difference(other)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = timedelta_range("2 days", "5 days", freq="D")
        idx_diff = index.difference(other)
        expected = TimedeltaIndex(["0 days", "1 days"], freq=None)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:18,代碼來源:test_timedelta.py

示例5: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self):
        # GH14323: difference of Period MUST preserve frequency
        # but the ability to union results must be preserved

        index = period_range("20160920", "20160925", freq="D")

        other = period_range("20160921", "20160924", freq="D")
        expected = PeriodIndex(["20160920", "20160925"], freq='D')
        idx_diff = index.difference(other)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = period_range("20160922", "20160925", freq="D")
        idx_diff = index.difference(other)
        expected = PeriodIndex(["20160920", "20160921"], freq='D')
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:19,代碼來源:test_period.py

示例6: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self, sort):
        # GH14323: difference of DatetimeIndex should not preserve frequency

        index = date_range("20160920", "20160925", freq="D")
        other = date_range("20160921", "20160924", freq="D")
        expected = DatetimeIndex(["20160920", "20160925"], freq=None)
        idx_diff = index.difference(other, sort)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = date_range("20160922", "20160925", freq="D")
        idx_diff = index.difference(other, sort)
        expected = DatetimeIndex(["20160920", "20160921"], freq=None)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:test_setops.py

示例7: test_difference_freq

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_attr_equal [as 別名]
def test_difference_freq(self):
        # GH14323: difference of DatetimeIndex should not preserve frequency

        index = date_range("20160920", "20160925", freq="D")
        other = date_range("20160921", "20160924", freq="D")
        expected = DatetimeIndex(["20160920", "20160925"], freq=None)
        idx_diff = index.difference(other)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected)

        other = date_range("20160922", "20160925", freq="D")
        idx_diff = index.difference(other)
        expected = DatetimeIndex(["20160920", "20160921"], freq=None)
        tm.assert_index_equal(idx_diff, expected)
        tm.assert_attr_equal('freq', idx_diff, expected) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:17,代碼來源:test_setops.py


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