本文整理汇总了Python中pandas.tseries.offsets.BMonthEnd方法的典型用法代码示例。如果您正苦于以下问题:Python offsets.BMonthEnd方法的具体用法?Python offsets.BMonthEnd怎么用?Python offsets.BMonthEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.tseries.offsets
的用法示例。
在下文中一共展示了offsets.BMonthEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shift
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_shift(self):
shifted = self.rng.shift(5)
assert shifted[0] == self.rng[5]
assert shifted.freq == self.rng.freq
shifted = self.rng.shift(-5)
assert shifted[5] == self.rng[0]
assert shifted.freq == self.rng.freq
shifted = self.rng.shift(0)
assert shifted[0] == self.rng[0]
assert shifted.freq == self.rng.freq
rng = date_range(START, END, freq=BMonthEnd())
shifted = rng.shift(1, freq=BDay())
assert shifted[0] == rng[0] + BDay()
示例2: test_asfreq
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_asfreq(self):
ts = Series([0., 1., 2.], index=[datetime(2009, 10, 30), datetime(
2009, 11, 30), datetime(2009, 12, 31)])
daily_ts = ts.asfreq('B')
monthly_ts = daily_ts.asfreq('BM')
tm.assert_series_equal(monthly_ts, ts)
daily_ts = ts.asfreq('B', method='pad')
monthly_ts = daily_ts.asfreq('BM')
tm.assert_series_equal(monthly_ts, ts)
daily_ts = ts.asfreq(BDay())
monthly_ts = daily_ts.asfreq(BMonthEnd())
tm.assert_series_equal(monthly_ts, ts)
result = ts[:0].asfreq('M')
assert len(result) == 0
assert result is not ts
daily_ts = ts.asfreq('D', fill_value=-1)
result = daily_ts.value_counts().sort_index()
expected = Series([60, 1, 1, 1],
index=[-1.0, 2.0, 1.0, 0.0]).sort_index()
tm.assert_series_equal(result, expected)
示例3: test_asfreq
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_asfreq(self):
offset_monthly = self.tsframe.asfreq(offsets.BMonthEnd())
rule_monthly = self.tsframe.asfreq('BM')
tm.assert_almost_equal(offset_monthly['A'], rule_monthly['A'])
filled = rule_monthly.asfreq('B', method='pad') # noqa
# TODO: actually check that this worked.
# don't forget!
filled_dep = rule_monthly.asfreq('B', method='pad') # noqa
# test does not blow up on length-0 DataFrame
zero_length = self.tsframe.reindex([])
result = zero_length.asfreq('BM')
assert result is not zero_length
示例4: test_shift
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_shift(self):
shifted = self.rng.shift(5)
assert shifted[0] == self.rng[5]
assert shifted.offset == self.rng.offset
shifted = self.rng.shift(-5)
assert shifted[5] == self.rng[0]
assert shifted.offset == self.rng.offset
shifted = self.rng.shift(0)
assert shifted[0] == self.rng[0]
assert shifted.offset == self.rng.offset
rng = date_range(START, END, freq=BMonthEnd())
shifted = rng.shift(1, freq=BDay())
assert shifted[0] == rng[0] + BDay()
示例5: test_union
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_union(self):
# overlapping
left = self.rng[:10]
right = self.rng[5:10]
the_union = left.union(right)
assert isinstance(the_union, DatetimeIndex)
# non-overlapping, gap in middle
left = self.rng[:5]
right = self.rng[10:]
the_union = left.union(right)
assert isinstance(the_union, Index)
# non-overlapping, no gap
left = self.rng[:5]
right = self.rng[5:10]
the_union = left.union(right)
assert isinstance(the_union, DatetimeIndex)
# order does not matter
tm.assert_index_equal(right.union(left), the_union)
# overlapping, but different offset
rng = date_range(START, END, freq=BMonthEnd())
the_union = self.rng.union(rng)
assert isinstance(the_union, DatetimeIndex)
示例6: test_outer_join
# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import BMonthEnd [as 别名]
def test_outer_join(self):
# should just behave as union
# overlapping
left = self.rng[:10]
right = self.rng[5:10]
the_join = left.join(right, how='outer')
assert isinstance(the_join, DatetimeIndex)
# non-overlapping, gap in middle
left = self.rng[:5]
right = self.rng[10:]
the_join = left.join(right, how='outer')
assert isinstance(the_join, DatetimeIndex)
assert the_join.freq is None
# non-overlapping, no gap
left = self.rng[:5]
right = self.rng[5:10]
the_join = left.join(right, how='outer')
assert isinstance(the_join, DatetimeIndex)
# overlapping, but different offset
rng = date_range(START, END, freq=BMonthEnd())
the_join = self.rng.join(rng, how='outer')
assert isinstance(the_join, DatetimeIndex)
assert the_join.freq is None