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


Python testing.makeCustomIndex方法代碼示例

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


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

示例1: test_join_on_fails_with_different_right_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_right_index(self):
        df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                        'b': np.random.randn(3)})
        df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                         'b': np.random.randn(10)},
                        index=tm.makeCustomIndex(10, 2))
        msg = (r'len\(left_on\) must equal the number of levels in the index'
               ' of "right"')
        with pytest.raises(ValueError, match=msg):
            merge(df, df2, left_on='a', right_index=True) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_join.py

示例2: test_join_on_fails_with_different_left_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_left_index(self):
        df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                        'b': np.random.randn(3)},
                       index=tm.makeCustomIndex(3, 2))
        df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                         'b': np.random.randn(10)})
        msg = (r'len\(right_on\) must equal the number of levels in the index'
               ' of "left"')
        with pytest.raises(ValueError, match=msg):
            merge(df, df2, right_on='b', left_index=True) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_join.py

示例3: test_join_on_fails_with_different_column_counts

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_column_counts(self):
        df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                        'b': np.random.randn(3)})
        df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                         'b': np.random.randn(10)},
                        index=tm.makeCustomIndex(10, 2))
        msg = r"len\(right_on\) must equal len\(left_on\)"
        with pytest.raises(ValueError, match=msg):
            merge(df, df2, right_on='a', left_on=['a', 'b']) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:11,代碼來源:test_join.py

示例4: test_raise_on_panel_with_multiindex

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_raise_on_panel_with_multiindex(self, parser, engine):
        p = tm.makePanel(7)
        p.items = tm.makeCustomIndex(len(p.items), nlevels=2)
        with pytest.raises(NotImplementedError):
            pd.eval('p + 1', parser=parser, engine=engine) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:test_query_eval.py

示例5: test_fails_on_no_datetime_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_fails_on_no_datetime_index(self):
        index_names = ('Int64Index', 'Index', 'Float64Index', 'MultiIndex')
        index_funcs = (tm.makeIntIndex,
                       tm.makeUnicodeIndex, tm.makeFloatIndex,
                       lambda m: tm.makeCustomIndex(m, 2))
        n = 2
        for name, func in zip(index_names, index_funcs):
            index = func(n)
            df = DataFrame({'a': np.random.randn(n)}, index=index)
            with tm.assert_raises_regex(TypeError,
                                        "Only valid with "
                                        "DatetimeIndex, TimedeltaIndex "
                                        "or PeriodIndex, but got an "
                                        "instance of %r" % name):
                df.groupby(TimeGrouper('D')) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:17,代碼來源:test_resample.py

示例6: test_join_on_fails_with_different_right_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_right_index(self):
        with pytest.raises(ValueError):
            df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)})
            df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)},
                            index=tm.makeCustomIndex(10, 2))
            merge(df, df2, left_on='a', right_index=True) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:10,代碼來源:test_join.py

示例7: test_join_on_fails_with_different_left_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_left_index(self):
        with pytest.raises(ValueError):
            df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)},
                           index=tm.makeCustomIndex(10, 2))
            df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)})
            merge(df, df2, right_on='b', left_index=True) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:10,代碼來源:test_join.py

示例8: test_join_on_fails_with_different_column_counts

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_column_counts(self):
        with pytest.raises(ValueError):
            df = DataFrame({'a': np.random.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)})
            df2 = DataFrame({'a': np.random.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)},
                            index=tm.makeCustomIndex(10, 2))
            merge(df, df2, right_on='a', left_on=['a', 'b']) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:10,代碼來源:test_join.py

示例9: test_fails_on_no_datetime_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_fails_on_no_datetime_index(self):
        index_names = ('Int64Index', 'PeriodIndex', 'Index', 'Float64Index',
                       'MultiIndex')
        index_funcs = (tm.makeIntIndex, tm.makePeriodIndex,
                       tm.makeUnicodeIndex, tm.makeFloatIndex,
                       lambda m: tm.makeCustomIndex(m, 2))
        n = 2
        for name, func in zip(index_names, index_funcs):
            index = func(n)
            df = DataFrame({'a': np.random.randn(n)}, index=index)
            with tm.assertRaisesRegexp(TypeError,
                                       "axis must be a DatetimeIndex, "
                                       "but got an instance of %r" % name):
                df.groupby(TimeGrouper('D')) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:16,代碼來源:test_resample.py

示例10: test_join_on_fails_with_different_right_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_right_index(self):
        with tm.assertRaises(ValueError):
            df = DataFrame({'a': tm.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)})
            df2 = DataFrame({'a': tm.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)},
                            index=tm.makeCustomIndex(10, 2))
            merge(df, df2, left_on='a', right_index=True) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:test_merge.py

示例11: test_join_on_fails_with_different_left_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_left_index(self):
        with tm.assertRaises(ValueError):
            df = DataFrame({'a': tm.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)},
                           index=tm.makeCustomIndex(10, 2))
            df2 = DataFrame({'a': tm.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)})
            merge(df, df2, right_on='b', left_index=True) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:test_merge.py

示例12: test_join_on_fails_with_different_column_counts

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_join_on_fails_with_different_column_counts(self):
        with tm.assertRaises(ValueError):
            df = DataFrame({'a': tm.choice(['m', 'f'], size=3),
                            'b': np.random.randn(3)})
            df2 = DataFrame({'a': tm.choice(['m', 'f'], size=10),
                             'b': np.random.randn(10)},
                            index=tm.makeCustomIndex(10, 2))
            merge(df, df2, right_on='a', left_on=['a', 'b']) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:test_merge.py

示例13: test_raise_on_panel_with_multiindex

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeCustomIndex [as 別名]
def test_raise_on_panel_with_multiindex(self, parser, engine):
        tm.skip_if_no_ne()
        p = tm.makePanel(7)
        p.items = tm.makeCustomIndex(len(p.items), nlevels=2)
        with pytest.raises(NotImplementedError):
            pd.eval('p + 1', parser=parser, engine=engine) 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:8,代碼來源:test_query_eval.py


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