Skip to content

Commit de502d2

Browse files
committed
BUG: DateRange.copy did not produce well-formed object. fixes GH #168
1 parent 10fa2b5 commit de502d2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ improvements
5454
- Excluding OLS degenerate unit test case that was causing platform specific
5555
failure (GH #149)
5656
- Skip blosc-dependent unit tests for PyTables < 2.2 (PR #137)
57+
- Calling `copy` on `DateRange` did not copy over attributes to the new object
58+
(GH #168)
5759

5860
Thanks
5961
------

pandas/core/index.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ def drop(self, labels):
433433
raise ValueError('labels %s not contained in axis' % labels[-mask])
434434
return self.delete(indexer)
435435

436+
def copy(self, order='C'):
437+
"""
438+
Overridden ndarray.copy to copy over attributes
439+
"""
440+
cp = self.view(np.ndarray).copy(order).view(type(self))
441+
cp.__dict__.update(self.__dict__)
442+
return cp
443+
436444
#----------------------------------------------------------------------
437445
# deprecated stuff
438446

pandas/tests/test_daterange.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def test_comparison(self):
8383
self.assert_(comp[11])
8484
self.assert_(not comp[9])
8585

86+
def test_copy(self):
87+
cp = self.rng.copy()
88+
repr(cp)
89+
self.assert_(cp.equals(self.rng))
90+
8691
def test_repr(self):
8792
# only really care that it works
8893
repr(self.rng)

0 commit comments

Comments
 (0)