当前位置: 首页>>代码示例>>Python>>正文


Python testing.K属性代码示例

本文整理汇总了Python中pandas.util.testing.K属性的典型用法代码示例。如果您正苦于以下问题:Python testing.K属性的具体用法?Python testing.K怎么用?Python testing.K使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pandas.util.testing的用法示例。


在下文中一共展示了testing.K属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_random_sample_set

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import K [as 别名]
def create_random_sample_set(n_samples, time_shift='120m', randomize_times=False, freq='60T'):
    # Create artificial data
    tm.K = 3
    tm.N = n_samples
    # Random data frame with an hourly index
    test_df = tm.makeTimeDataFrame(freq=freq)
    # Turn the index into a column labeled 'index'
    test_df = test_df.reset_index()
    if randomize_times:
        tm.K = 1
        # Subtract and adds random time deltas to the index column, to create the prediction and evaluation times
        rand_fact = tm.makeDataFrame().reset_index(drop=True).squeeze().iloc[:len(test_df)].abs()
        test_df['index'] = test_df['index'].subtract(rand_fact.apply(lambda x: x * pd.Timedelta(time_shift)))
        rand_fact = tm.makeDataFrame().reset_index(drop=True).squeeze().iloc[:len(test_df)].abs()
        test_df['index2'] = test_df['index'].add(rand_fact.apply(lambda x: x * pd.Timedelta(time_shift)))
    else:
        test_df['index2'] = test_df['index'].apply(lambda x: x + pd.Timedelta(time_shift))
    # Sort the data frame by prediction time
    test_df = test_df.sort_values('index')
    X = test_df[['A', 'B', 'C']]
    pred_times = test_df['index']
    exit_times = test_df['index2']
    return X, pred_times, exit_times 
开发者ID:sam31415,项目名称:timeseriescv,代码行数:25,代码来源:test_cross_validation.py

示例2: test_panel_join_many

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import K [as 别名]
def test_panel_join_many(self):
        with catch_warnings(record=True):
            tm.K = 10
            panel = tm.makePanel()
            tm.K = 4

            panels = [panel.iloc[:2], panel.iloc[2:6], panel.iloc[6:]]

            joined = panels[0].join(panels[1:])
            tm.assert_panel_equal(joined, panel)

            panels = [panel.iloc[:2, :-5],
                      panel.iloc[2:6, 2:],
                      panel.iloc[6:, 5:-7]]

            data_dict = {}
            for p in panels:
                data_dict.update(p.iteritems())

            joined = panels[0].join(panels[1:], how='inner')
            expected = pd.Panel.from_dict(data_dict, intersect=True)
            tm.assert_panel_equal(joined, expected)

            joined = panels[0].join(panels[1:], how='outer')
            expected = pd.Panel.from_dict(data_dict, intersect=False)
            tm.assert_panel_equal(joined, expected)

            # edge cases
            msg = "Suffixes not supported when passing multiple panels"
            with pytest.raises(ValueError, match=msg):
                panels[0].join(panels[1:], how='outer', lsuffix='foo',
                               rsuffix='bar')
            msg = "Right join not supported with multiple panels"
            with pytest.raises(ValueError, match=msg):
                panels[0].join(panels[1:], how='right') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:37,代码来源:test_join.py

示例3: test_panel_join_many

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import K [as 别名]
def test_panel_join_many(self):
        with catch_warnings(record=True):
            tm.K = 10
            panel = tm.makePanel()
            tm.K = 4

            panels = [panel.iloc[:2], panel.iloc[2:6], panel.iloc[6:]]

            joined = panels[0].join(panels[1:])
            tm.assert_panel_equal(joined, panel)

            panels = [panel.iloc[:2, :-5],
                      panel.iloc[2:6, 2:],
                      panel.iloc[6:, 5:-7]]

            data_dict = {}
            for p in panels:
                data_dict.update(p.iteritems())

            joined = panels[0].join(panels[1:], how='inner')
            expected = pd.Panel.from_dict(data_dict, intersect=True)
            tm.assert_panel_equal(joined, expected)

            joined = panels[0].join(panels[1:], how='outer')
            expected = pd.Panel.from_dict(data_dict, intersect=False)
            tm.assert_panel_equal(joined, expected)

            # edge cases
            pytest.raises(ValueError, panels[0].join, panels[1:],
                          how='outer', lsuffix='foo', rsuffix='bar')
            pytest.raises(ValueError, panels[0].join, panels[1:],
                          how='right') 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:34,代码来源:test_join.py

示例4: test_panel_join_many

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import K [as 别名]
def test_panel_join_many(self):
        tm.K = 10
        panel = tm.makePanel()
        tm.K = 4

        panels = [panel.ix[:2], panel.ix[2:6], panel.ix[6:]]

        joined = panels[0].join(panels[1:])
        tm.assert_panel_equal(joined, panel)

        panels = [panel.ix[:2, :-5], panel.ix[2:6, 2:], panel.ix[6:, 5:-7]]

        data_dict = {}
        for p in panels:
            data_dict.update(compat.iteritems(p))

        joined = panels[0].join(panels[1:], how='inner')
        expected = Panel.from_dict(data_dict, intersect=True)
        tm.assert_panel_equal(joined, expected)

        joined = panels[0].join(panels[1:], how='outer')
        expected = Panel.from_dict(data_dict, intersect=False)
        tm.assert_panel_equal(joined, expected)

        # edge cases
        self.assertRaises(ValueError, panels[0].join, panels[1:],
                          how='outer', lsuffix='foo', rsuffix='bar')
        self.assertRaises(ValueError, panels[0].join, panels[1:],
                          how='right') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:test_merge.py


注:本文中的pandas.util.testing.K属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。