当前位置: 首页>>代码示例>>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;未经允许,请勿转载。