Python pandas.tseries.offsets.CDay() Examples
The following are 15
code examples of pandas.tseries.offsets.CDay().
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_indexing.py From recruit with Apache License 2.0 | 6 votes |
def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq='C') smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5] assert sliced.freq == CDay() * 5 fancy_indexed = rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert rng[4] == rng[np.int_(4)]
Example #2
Source File: test_ops.py From recruit with Apache License 2.0 | 6 votes |
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 with warnings.catch_warnings(record=True): warnings.simplefilter("ignore", pd.errors.PerformanceWarning) rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #3
Source File: test_indexing.py From vnpy_crypto with MIT License | 6 votes |
def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq='C') smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5] assert sliced.freq == CDay() * 5 fancy_indexed = rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert rng[4] == rng[np.int_(4)]
Example #4
Source File: test_ops.py From vnpy_crypto with MIT License | 6 votes |
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 # PerformanceWarning with warnings.catch_warnings(record=True): rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #5
Source File: test_indexing.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq='C') smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5] assert sliced.freq == CDay() * 5 fancy_indexed = rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert rng[4] == rng[np.int_(4)]
Example #6
Source File: test_ops.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
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 with warnings.catch_warnings(record=True): warnings.simplefilter("ignore", pd.errors.PerformanceWarning) rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #7
Source File: test_ops.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_getitem(self): smaller = self.rng[:5] exp = DatetimeIndex(self.rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.offset == self.rng.offset sliced = self.rng[::5] assert sliced.offset == CDay() * 5 fancy_indexed = self.rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert self.rng[4] == self.rng[np.int_(4)]
Example #8
Source File: test_ops.py From elasticintel with GNU General Public License v3.0 | 6 votes |
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 # PerformanceWarning with warnings.catch_warnings(record=True): rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #9
Source File: test_indexing.py From coffeegrindsize with MIT License | 6 votes |
def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq='C') smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5] assert sliced.freq == CDay() * 5 fancy_indexed = rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert rng[4] == rng[np.int_(4)]
Example #10
Source File: test_ops.py From coffeegrindsize with MIT License | 6 votes |
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 with warnings.catch_warnings(record=True): warnings.simplefilter("ignore", pd.errors.PerformanceWarning) rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #11
Source File: test_indexing.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq='C') smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5] assert sliced.freq == CDay() * 5 fancy_indexed = rng[[4, 3, 2, 1, 0]] assert len(fancy_indexed) == 5 assert isinstance(fancy_indexed, DatetimeIndex) assert fancy_indexed.freq is None # 32-bit vs. 64-bit platforms assert rng[4] == rng[np.int_(4)]
Example #12
Source File: test_ops.py From twitter-stock-recommendation with MIT License | 6 votes |
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 # PerformanceWarning with warnings.catch_warnings(record=True): rng = date_range(START, END, freq=BMonthEnd()) shifted = rng.shift(1, freq=CDay()) assert shifted[0] == rng[0] + CDay()
Example #13
Source File: datetimes.py From recruit with Apache License 2.0 | 4 votes |
def cdate_range(start=None, end=None, periods=None, freq='C', tz=None, normalize=True, name=None, closed=None, **kwargs): """ Return a fixed frequency DatetimeIndex, with CustomBusinessDay as the default frequency .. deprecated:: 0.21.0 Parameters ---------- start : string or datetime-like, default None Left bound for generating dates end : string or datetime-like, default None Right bound for generating dates periods : integer, default None Number of periods to generate freq : string or DateOffset, default 'C' (CustomBusinessDay) Frequency strings can have multiples, e.g. '5H' tz : string, default None Time zone name for returning localized DatetimeIndex, for example Asia/Beijing normalize : bool, default False Normalize start/end dates to midnight before generating date range name : string, default None Name of the resulting DatetimeIndex weekmask : string, Default 'Mon Tue Wed Thu Fri' weekmask of valid business days, passed to ``numpy.busdaycalendar`` holidays : list list/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar`` closed : string, default None Make the interval closed with respect to the given frequency to the 'left', 'right', or both sides (None) Notes ----- Of the three parameters: ``start``, ``end``, and ``periods``, exactly two must be specified. To learn more about the frequency strings, please see `this link <http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__. Returns ------- rng : DatetimeIndex """ warnings.warn("cdate_range is deprecated and will be removed in a future " "version, instead use pd.bdate_range(..., freq='{freq}')" .format(freq=freq), FutureWarning, stacklevel=2) if freq == 'C': holidays = kwargs.pop('holidays', []) weekmask = kwargs.pop('weekmask', 'Mon Tue Wed Thu Fri') freq = CDay(holidays=holidays, weekmask=weekmask) return date_range(start=start, end=end, periods=periods, freq=freq, tz=tz, normalize=normalize, name=name, closed=closed, **kwargs)
Example #14
Source File: index.py From Computable with MIT License | 4 votes |
def cdate_range(start=None, end=None, periods=None, freq='C', tz=None, normalize=True, name=None, closed=None, **kwargs): """ **EXPERIMENTAL** Return a fixed frequency datetime index, with CustomBusinessDay as the default frequency .. warning:: EXPERIMENTAL The CustomBusinessDay class is not officially supported and the API is likely to change in future versions. Use this at your own risk. Parameters ---------- start : string or datetime-like, default None Left bound for generating dates end : string or datetime-like, default None Right bound for generating dates periods : integer or None, default None If None, must specify start and end freq : string or DateOffset, default 'C' (CustomBusinessDay) Frequency strings can have multiples, e.g. '5H' tz : string or None Time zone name for returning localized DatetimeIndex, for example Asia/Beijing normalize : bool, default False Normalize start/end dates to midnight before generating date range name : str, default None Name for the resulting index weekmask : str, Default 'Mon Tue Wed Thu Fri' weekmask of valid business days, passed to ``numpy.busdaycalendar`` holidays : list list/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar`` closed : string or None, default None Make the interval closed with respect to the given frequency to the 'left', 'right', or both sides (None) Notes ----- 2 of start, end, or periods must be specified Returns ------- rng : DatetimeIndex """ if freq=='C': holidays = kwargs.pop('holidays', []) weekmask = kwargs.pop('weekmask', 'Mon Tue Wed Thu Fri') freq = CDay(holidays=holidays, weekmask=weekmask) return DatetimeIndex(start=start, end=end, periods=periods, freq=freq, tz=tz, normalize=normalize, name=name, closed=closed, **kwargs)
Example #15
Source File: datetimes.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def cdate_range(start=None, end=None, periods=None, freq='C', tz=None, normalize=True, name=None, closed=None, **kwargs): """ Return a fixed frequency DatetimeIndex, with CustomBusinessDay as the default frequency .. deprecated:: 0.21.0 Parameters ---------- start : string or datetime-like, default None Left bound for generating dates end : string or datetime-like, default None Right bound for generating dates periods : integer, default None Number of periods to generate freq : string or DateOffset, default 'C' (CustomBusinessDay) Frequency strings can have multiples, e.g. '5H' tz : string, default None Time zone name for returning localized DatetimeIndex, for example Asia/Beijing normalize : bool, default False Normalize start/end dates to midnight before generating date range name : string, default None Name of the resulting DatetimeIndex weekmask : string, Default 'Mon Tue Wed Thu Fri' weekmask of valid business days, passed to ``numpy.busdaycalendar`` holidays : list list/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar`` closed : string, default None Make the interval closed with respect to the given frequency to the 'left', 'right', or both sides (None) Notes ----- Of the three parameters: ``start``, ``end``, and ``periods``, exactly two must be specified. To learn more about the frequency strings, please see `this link <http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__. Returns ------- rng : DatetimeIndex """ warnings.warn("cdate_range is deprecated and will be removed in a future " "version, instead use pd.bdate_range(..., freq='{freq}')" .format(freq=freq), FutureWarning, stacklevel=2) if freq == 'C': holidays = kwargs.pop('holidays', []) weekmask = kwargs.pop('weekmask', 'Mon Tue Wed Thu Fri') freq = CDay(holidays=holidays, weekmask=weekmask) return date_range(start=start, end=end, periods=periods, freq=freq, tz=tz, normalize=normalize, name=name, closed=closed, **kwargs)