Python pandas.offsets.DateOffset() Examples

The following are 18 code examples of pandas.offsets.DateOffset(). 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.offsets , or try the search function .
Example #1
Source File: test_date_range.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #2
Source File: test_date_range.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected) 
Example #3
Source File: test_date_range.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #4
Source File: test_date_range.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #5
Source File: test_date_range.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #6
Source File: test_date_range.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected) 
Example #7
Source File: test_date_range.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #8
Source File: test_date_range.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected) 
Example #9
Source File: test_date_range.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #10
Source File: test_date_range.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #11
Source File: test_date_range.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #12
Source File: test_date_range.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected) 
Example #13
Source File: test_date_range.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #14
Source File: test_date_range.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected) 
Example #15
Source File: test_date_range.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #16
Source File: test_date_range.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_catch_infinite_loop(self):
        offset = offsets.DateOffset(minute=5)
        # blow up, don't loop forever
        pytest.raises(Exception, date_range, datetime(2011, 11, 11),
                      datetime(2011, 11, 12), freq=offset) 
Example #17
Source File: test_date_range.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_cached_range_bug(self):
        rng = date_range('2010-09-01 05:00:00', periods=50,
                         freq=DateOffset(hours=6))
        assert len(rng) == 50
        assert rng[0] == datetime(2010, 9, 1, 5) 
Example #18
Source File: test_date_range.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_range_bug(self):
        # GH #770
        offset = DateOffset(months=3)
        result = date_range("2011-1-1", "2012-1-31", freq=offset)

        start = datetime(2011, 1, 1)
        expected = DatetimeIndex([start + i * offset for i in range(5)])
        tm.assert_index_equal(result, expected)