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


Python offsets.BDay方法代码示例

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


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

示例1: test_scalar

# 需要导入模块: from pandas import offsets [as 别名]
# 或者: from pandas.offsets import BDay [as 别名]
def test_scalar(self):

        N = 30
        rng = date_range('1/1/1990', periods=N, freq='53s')
        ts = Series(np.arange(N), index=rng)
        ts[5:10] = np.NaN
        ts[15:20] = np.NaN

        val1 = ts.asof(ts.index[7])
        val2 = ts.asof(ts.index[19])

        assert val1 == ts[4]
        assert val2 == ts[14]

        # accepts strings
        val1 = ts.asof(str(ts.index[7]))
        assert val1 == ts[4]

        # in there
        result = ts.asof(ts.index[3])
        assert result == ts[3]

        # no as of value
        d = ts.index[0] - offsets.BDay()
        assert np.isnan(ts.asof(d)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:test_asof.py

示例2: test_construction_with_ndarray

# 需要导入模块: from pandas import offsets [as 别名]
# 或者: from pandas.offsets import BDay [as 别名]
def test_construction_with_ndarray(self):
        # GH 5152
        dates = [datetime(2013, 10, 7),
                 datetime(2013, 10, 8),
                 datetime(2013, 10, 9)]
        data = DatetimeIndex(dates, freq=pd.tseries.frequencies.BDay()).values
        result = DatetimeIndex(data, freq=pd.tseries.frequencies.BDay())
        expected = DatetimeIndex(['2013-10-07',
                                  '2013-10-08',
                                  '2013-10-09'],
                                 freq='B')
        tm.assert_index_equal(result, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:14,代码来源:test_construction.py

示例3: test_periodindex

# 需要导入模块: from pandas import offsets [as 别名]
# 或者: from pandas.offsets import BDay [as 别名]
def test_periodindex(self):
        from pandas import period_range, PeriodIndex
        # array or list or dates
        N = 50
        rng = period_range('1/1/1990', periods=N, freq='H')
        ts = Series(np.random.randn(N), index=rng)
        ts[15:30] = np.nan
        dates = date_range('1/1/1990', periods=N * 3, freq='37min')

        result = ts.asof(dates)
        assert notna(result).all()
        lb = ts.index[14]
        ub = ts.index[30]

        result = ts.asof(list(dates))
        assert notna(result).all()
        lb = ts.index[14]
        ub = ts.index[30]

        pix = PeriodIndex(result.index.values, freq='H')
        mask = (pix >= lb) & (pix < ub)
        rs = result[mask]
        assert (rs == ts[lb]).all()

        ts[5:10] = np.nan
        ts[15:20] = np.nan

        val1 = ts.asof(ts.index[7])
        val2 = ts.asof(ts.index[19])

        assert val1 == ts[4]
        assert val2 == ts[14]

        # accepts strings
        val1 = ts.asof(str(ts.index[7]))
        assert val1 == ts[4]

        # in there
        assert ts.asof(ts.index[3]) == ts[3]

        # no as of value
        d = ts.index[0].to_timestamp() - offsets.BDay()
        assert isna(ts.asof(d)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:45,代码来源:test_asof.py


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