Python pandas.tseries.offsets.MonthEnd() Examples
The following are 30
code examples of pandas.tseries.offsets.MonthEnd().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.tseries.offsets
, or try the search function
.
Example #1
Source File: test_libfrequencies.py From vnpy_crypto with MIT License | 7 votes |
def test_is_superperiod_subperiod(): # input validation assert not (is_superperiod(offsets.YearEnd(), None)) assert not (is_subperiod(offsets.MonthEnd(), None)) assert not (is_superperiod(None, offsets.YearEnd())) assert not (is_subperiod(None, offsets.MonthEnd())) assert not (is_superperiod(None, None)) assert not (is_subperiod(None, None)) assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd())) assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd())) assert (is_superperiod(offsets.Hour(), offsets.Minute())) assert (is_subperiod(offsets.Minute(), offsets.Hour())) assert (is_superperiod(offsets.Second(), offsets.Milli())) assert (is_subperiod(offsets.Milli(), offsets.Second())) assert (is_superperiod(offsets.Milli(), offsets.Micro())) assert (is_subperiod(offsets.Micro(), offsets.Milli())) assert (is_superperiod(offsets.Micro(), offsets.Nano())) assert (is_subperiod(offsets.Nano(), offsets.Micro()))
Example #2
Source File: test_setops.py From recruit with Apache License 2.0 | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #3
Source File: test_libfrequencies.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_is_superperiod_subperiod(): # input validation assert not (is_superperiod(offsets.YearEnd(), None)) assert not (is_subperiod(offsets.MonthEnd(), None)) assert not (is_superperiod(None, offsets.YearEnd())) assert not (is_subperiod(None, offsets.MonthEnd())) assert not (is_superperiod(None, None)) assert not (is_subperiod(None, None)) assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd())) assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd())) assert (is_superperiod(offsets.Hour(), offsets.Minute())) assert (is_subperiod(offsets.Minute(), offsets.Hour())) assert (is_superperiod(offsets.Second(), offsets.Milli())) assert (is_subperiod(offsets.Milli(), offsets.Second())) assert (is_superperiod(offsets.Milli(), offsets.Micro())) assert (is_subperiod(offsets.Micro(), offsets.Milli())) assert (is_superperiod(offsets.Micro(), offsets.Nano())) assert (is_subperiod(offsets.Nano(), offsets.Micro()))
Example #4
Source File: test_setops.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_month_range_union_tz_dateutil(self): from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #5
Source File: test_setops.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #6
Source File: test_setops.py From coffeegrindsize with MIT License | 6 votes |
def test_month_range_union_tz_dateutil(self): from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #7
Source File: test_setops.py From coffeegrindsize with MIT License | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #8
Source File: test_frequencies.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_is_superperiod_subperiod(): # input validation assert not (frequencies.is_superperiod(offsets.YearEnd(), None)) assert not (frequencies.is_subperiod(offsets.MonthEnd(), None)) assert not (frequencies.is_superperiod(None, offsets.YearEnd())) assert not (frequencies.is_subperiod(None, offsets.MonthEnd())) assert not (frequencies.is_superperiod(None, None)) assert not (frequencies.is_subperiod(None, None)) assert (frequencies.is_superperiod(offsets.YearEnd(), offsets.MonthEnd())) assert (frequencies.is_subperiod(offsets.MonthEnd(), offsets.YearEnd())) assert (frequencies.is_superperiod(offsets.Hour(), offsets.Minute())) assert (frequencies.is_subperiod(offsets.Minute(), offsets.Hour())) assert (frequencies.is_superperiod(offsets.Second(), offsets.Milli())) assert (frequencies.is_subperiod(offsets.Milli(), offsets.Second())) assert (frequencies.is_superperiod(offsets.Milli(), offsets.Micro())) assert (frequencies.is_subperiod(offsets.Micro(), offsets.Milli())) assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano())) assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro()))
Example #9
Source File: test_setops.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_month_range_union_tz_dateutil(self): tm._skip_if_windows_python_3() from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #10
Source File: test_setops.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #11
Source File: test_setops.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_month_range_union_tz_dateutil(self): from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #12
Source File: test_setops.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #13
Source File: test_setops.py From recruit with Apache License 2.0 | 6 votes |
def test_month_range_union_tz_dateutil(self): from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #14
Source File: test_setops.py From vnpy_crypto with MIT License | 6 votes |
def test_month_range_union_tz_dateutil(self): from pandas._libs.tslibs.timezones import dateutil_gettz tz = dateutil_gettz('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #15
Source File: test_setops.py From vnpy_crypto with MIT License | 6 votes |
def test_month_range_union_tz_pytz(self): from pytz import timezone tz = timezone('US/Eastern') early_start = datetime(2011, 1, 1) early_end = datetime(2011, 3, 1) late_start = datetime(2011, 3, 1) late_end = datetime(2011, 5, 1) early_dr = date_range(start=early_start, end=early_end, tz=tz, freq=MonthEnd()) late_dr = date_range(start=late_start, end=late_end, tz=tz, freq=MonthEnd()) early_dr.union(late_dr)
Example #16
Source File: daycounts.py From FinanceHub with MIT License | 5 votes |
def eom(d, offset=0): """Unmodified end-of-month. Returns the last date of month for the same month and year as input d The offset parameter represents the number of months that will be added (if offset > 0) or subtracted (if offset < 0) to input date d. This is especially useful for offset = -1, which gives you the EOM of previous month, for example. """ d = to_datetime(d) # Adding straight up the MonthEnd works as expected for MonthEnd(0), # but it gives weird results if using MonthEnd(1) and the input is # the last date of month. We leave the offset to a different function return d + DateOffset(months=offset) + MonthEnd(0)
Example #17
Source File: test_panel.py From recruit with Apache License 2.0 | 5 votes |
def test_setitem_ndarray(self): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #18
Source File: test_panel.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_setitem_ndarray(self): with catch_warnings(record=True): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #19
Source File: test_pickle.py From recruit with Apache License 2.0 | 5 votes |
def compare_index_period(result, expected, typ, version): tm.assert_index_equal(result, expected) assert isinstance(result.freq, MonthEnd) assert result.freq == MonthEnd() assert result.freqstr == 'M' tm.assert_index_equal(result.shift(2), expected.shift(2))
Example #20
Source File: test_panel.py From vnpy_crypto with MIT License | 5 votes |
def test_setitem_ndarray(self): with catch_warnings(record=True): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #21
Source File: test_panel.py From coffeegrindsize with MIT License | 5 votes |
def test_setitem_ndarray(self): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #22
Source File: test_panel.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_setitem_ndarray(self): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #23
Source File: test_panel.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_setitem_ndarray(self): with catch_warnings(record=True): timeidx = date_range(start=datetime(2009, 1, 1), end=datetime(2009, 12, 31), freq=MonthEnd()) lons_coarse = np.linspace(-177.5, 177.5, 72) lats_coarse = np.linspace(-87.5, 87.5, 36) P = Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse) data = np.random.randn(72 * 36).reshape((72, 36)) key = datetime(2009, 2, 28) P[key] = data assert_almost_equal(P[key].values, data)
Example #24
Source File: test_pickle.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def compare_index_period(result, expected, typ, version): tm.assert_index_equal(result, expected) assert isinstance(result.freq, MonthEnd) assert result.freq == MonthEnd() assert result.freqstr == 'M' tm.assert_index_equal(result.shift(2), expected.shift(2))
Example #25
Source File: test_frequencies.py From Computable with MIT License | 5 votes |
def test_is_superperiod_subperiod(): assert(fmod.is_superperiod(offsets.YearEnd(), offsets.MonthEnd())) assert(fmod.is_subperiod(offsets.MonthEnd(), offsets.YearEnd())) assert(fmod.is_superperiod(offsets.Hour(), offsets.Minute())) assert(fmod.is_subperiod(offsets.Minute(), offsets.Hour()))
Example #26
Source File: test_frequencies.py From elasticintel with GNU General Public License v3.0 | 4 votes |
def test_get_freq_code(self): # frequency str assert (frequencies.get_freq_code('A') == (frequencies.get_freq('A'), 1)) assert (frequencies.get_freq_code('3D') == (frequencies.get_freq('D'), 3)) assert (frequencies.get_freq_code('-2M') == (frequencies.get_freq('M'), -2)) # tuple assert (frequencies.get_freq_code(('D', 1)) == (frequencies.get_freq('D'), 1)) assert (frequencies.get_freq_code(('A', 3)) == (frequencies.get_freq('A'), 3)) assert (frequencies.get_freq_code(('M', -2)) == (frequencies.get_freq('M'), -2)) # numeric tuple assert frequencies.get_freq_code((1000, 1)) == (1000, 1) # offsets assert (frequencies.get_freq_code(offsets.Day()) == (frequencies.get_freq('D'), 1)) assert (frequencies.get_freq_code(offsets.Day(3)) == (frequencies.get_freq('D'), 3)) assert (frequencies.get_freq_code(offsets.Day(-2)) == (frequencies.get_freq('D'), -2)) assert (frequencies.get_freq_code(offsets.MonthEnd()) == (frequencies.get_freq('M'), 1)) assert (frequencies.get_freq_code(offsets.MonthEnd(3)) == (frequencies.get_freq('M'), 3)) assert (frequencies.get_freq_code(offsets.MonthEnd(-2)) == (frequencies.get_freq('M'), -2)) assert (frequencies.get_freq_code(offsets.Week()) == (frequencies.get_freq('W'), 1)) assert (frequencies.get_freq_code(offsets.Week(3)) == (frequencies.get_freq('W'), 3)) assert (frequencies.get_freq_code(offsets.Week(-2)) == (frequencies.get_freq('W'), -2)) # Monday is weekday=0 assert (frequencies.get_freq_code(offsets.Week(weekday=1)) == (frequencies.get_freq('W-TUE'), 1)) assert (frequencies.get_freq_code(offsets.Week(3, weekday=0)) == (frequencies.get_freq('W-MON'), 3)) assert (frequencies.get_freq_code(offsets.Week(-2, weekday=4)) == (frequencies.get_freq('W-FRI'), -2))
Example #27
Source File: test_frequencies.py From vnpy_crypto with MIT License | 4 votes |
def test_get_freq_code(self): # frequency str assert (frequencies.get_freq_code('A') == (frequencies.get_freq('A'), 1)) assert (frequencies.get_freq_code('3D') == (frequencies.get_freq('D'), 3)) assert (frequencies.get_freq_code('-2M') == (frequencies.get_freq('M'), -2)) # tuple assert (frequencies.get_freq_code(('D', 1)) == (frequencies.get_freq('D'), 1)) assert (frequencies.get_freq_code(('A', 3)) == (frequencies.get_freq('A'), 3)) assert (frequencies.get_freq_code(('M', -2)) == (frequencies.get_freq('M'), -2)) # numeric tuple assert frequencies.get_freq_code((1000, 1)) == (1000, 1) # offsets assert (frequencies.get_freq_code(offsets.Day()) == (frequencies.get_freq('D'), 1)) assert (frequencies.get_freq_code(offsets.Day(3)) == (frequencies.get_freq('D'), 3)) assert (frequencies.get_freq_code(offsets.Day(-2)) == (frequencies.get_freq('D'), -2)) assert (frequencies.get_freq_code(offsets.MonthEnd()) == (frequencies.get_freq('M'), 1)) assert (frequencies.get_freq_code(offsets.MonthEnd(3)) == (frequencies.get_freq('M'), 3)) assert (frequencies.get_freq_code(offsets.MonthEnd(-2)) == (frequencies.get_freq('M'), -2)) assert (frequencies.get_freq_code(offsets.Week()) == (frequencies.get_freq('W'), 1)) assert (frequencies.get_freq_code(offsets.Week(3)) == (frequencies.get_freq('W'), 3)) assert (frequencies.get_freq_code(offsets.Week(-2)) == (frequencies.get_freq('W'), -2)) # Monday is weekday=0 assert (frequencies.get_freq_code(offsets.Week(weekday=1)) == (frequencies.get_freq('W-TUE'), 1)) assert (frequencies.get_freq_code(offsets.Week(3, weekday=0)) == (frequencies.get_freq('W-MON'), 3)) assert (frequencies.get_freq_code(offsets.Week(-2, weekday=4)) == (frequencies.get_freq('W-FRI'), -2))
Example #28
Source File: datasets.py From pyfinance with MIT License | 4 votes |
def load_shiller(): """Load market & macroeconomic data from Robert Shiller's website. Returns ------- iedata : pd.DataFrame Time series of S&P 500 and interest rate variables. Example ------- >>> from pyfinance import datasets >>> shiller = datasets.load_shiller() >>> shiller.iloc[:7, :5] sp50p sp50d sp50e cpi real_rate date 1871-01-31 4.44 0.26 0.4 12.4641 5.3200 1871-02-28 4.50 0.26 0.4 12.8446 5.3233 1871-03-31 4.61 0.26 0.4 13.0350 5.3267 1871-04-30 4.74 0.26 0.4 12.5592 5.3300 1871-05-31 4.86 0.26 0.4 12.2738 5.3333 1871-06-30 4.82 0.26 0.4 12.0835 5.3367 1871-07-31 4.73 0.26 0.4 12.0835 5.3400 .. _ONLINE DATA ROBERT SHILLER: http://www.econ.yale.edu/~shiller/data.htm """ xls = "http://www.econ.yale.edu/~shiller/data/ie_data.xls" cols = [ "date", "sp50p", "sp50d", "sp50e", "cpi", "frac", "real_rate", "real_sp50p", "real_sp50d", "real_sp50e", "cape", ] iedata = pd.read_excel( xls, sheet_name="Data", skiprows=7, skip_footer=1, names=cols ).drop("frac", axis=1) dt = iedata["date"].astype(str).str.replace(".", "") + "01" iedata["date"] = pd.to_datetime(dt, format="%Y%m%d") + offsets.MonthEnd() return iedata.set_index("date")
Example #29
Source File: test_frequencies.py From coffeegrindsize with MIT License | 4 votes |
def test_get_freq_code(self): # frequency str assert (get_freq_code('A') == (get_freq('A'), 1)) assert (get_freq_code('3D') == (get_freq('D'), 3)) assert (get_freq_code('-2M') == (get_freq('M'), -2)) # tuple assert (get_freq_code(('D', 1)) == (get_freq('D'), 1)) assert (get_freq_code(('A', 3)) == (get_freq('A'), 3)) assert (get_freq_code(('M', -2)) == (get_freq('M'), -2)) # numeric tuple assert get_freq_code((1000, 1)) == (1000, 1) # offsets assert (get_freq_code(offsets.Day()) == (get_freq('D'), 1)) assert (get_freq_code(offsets.Day(3)) == (get_freq('D'), 3)) assert (get_freq_code(offsets.Day(-2)) == (get_freq('D'), -2)) assert (get_freq_code(offsets.MonthEnd()) == (get_freq('M'), 1)) assert (get_freq_code(offsets.MonthEnd(3)) == (get_freq('M'), 3)) assert (get_freq_code(offsets.MonthEnd(-2)) == (get_freq('M'), -2)) assert (get_freq_code(offsets.Week()) == (get_freq('W'), 1)) assert (get_freq_code(offsets.Week(3)) == (get_freq('W'), 3)) assert (get_freq_code(offsets.Week(-2)) == (get_freq('W'), -2)) # Monday is weekday=0 assert (get_freq_code(offsets.Week(weekday=1)) == (get_freq('W-TUE'), 1)) assert (get_freq_code(offsets.Week(3, weekday=0)) == (get_freq('W-MON'), 3)) assert (get_freq_code(offsets.Week(-2, weekday=4)) == (get_freq('W-FRI'), -2))
Example #30
Source File: test_frequencies.py From recruit with Apache License 2.0 | 4 votes |
def test_get_freq_code(self): # frequency str assert (get_freq_code('A') == (get_freq('A'), 1)) assert (get_freq_code('3D') == (get_freq('D'), 3)) assert (get_freq_code('-2M') == (get_freq('M'), -2)) # tuple assert (get_freq_code(('D', 1)) == (get_freq('D'), 1)) assert (get_freq_code(('A', 3)) == (get_freq('A'), 3)) assert (get_freq_code(('M', -2)) == (get_freq('M'), -2)) # numeric tuple assert get_freq_code((1000, 1)) == (1000, 1) # offsets assert (get_freq_code(offsets.Day()) == (get_freq('D'), 1)) assert (get_freq_code(offsets.Day(3)) == (get_freq('D'), 3)) assert (get_freq_code(offsets.Day(-2)) == (get_freq('D'), -2)) assert (get_freq_code(offsets.MonthEnd()) == (get_freq('M'), 1)) assert (get_freq_code(offsets.MonthEnd(3)) == (get_freq('M'), 3)) assert (get_freq_code(offsets.MonthEnd(-2)) == (get_freq('M'), -2)) assert (get_freq_code(offsets.Week()) == (get_freq('W'), 1)) assert (get_freq_code(offsets.Week(3)) == (get_freq('W'), 3)) assert (get_freq_code(offsets.Week(-2)) == (get_freq('W'), -2)) # Monday is weekday=0 assert (get_freq_code(offsets.Week(weekday=1)) == (get_freq('W-TUE'), 1)) assert (get_freq_code(offsets.Week(3, weekday=0)) == (get_freq('W-MON'), 3)) assert (get_freq_code(offsets.Week(-2, weekday=4)) == (get_freq('W-FRI'), -2))