Skip to content

Commit

Permalink
COMPAT: py2.7 compat for Timestamp.replace (pandas-dev#15030)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback authored Jan 1, 2017
1 parent b81e500 commit 6141754
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Bug Fixes

- Bug in ``Series`` construction with a datetimetz (:issue:`14928`)


- Bug in compat for passing long integers to ``Timestamp.replace`` (:issue:`15030`)



Expand Down
11 changes: 11 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,17 @@ def test_timestamp_date_out_of_range(self):
self.assertRaises(ValueError, DatetimeIndex, ['1400-01-01'])
self.assertRaises(ValueError, DatetimeIndex, [datetime(1400, 1, 1)])

def test_compat_replace(self):
# https://github.com/statsmodels/statsmodels/issues/3349
# replace should take ints/longs for compat

for f in [compat.long, int]:
result = date_range(Timestamp('1960-04-01 00:00:00',
freq='QS-JAN'),
periods=f(76),
freq='QS-JAN')
self.assertEqual(len(result), 76)

def test_timestamp_repr(self):
# pre-1900
stamp = Timestamp('1850-01-01', tz='US/Eastern')
Expand Down
2 changes: 1 addition & 1 deletion pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ class Timestamp(_Timestamp):
# replace
def validate(k, v):
""" validate integers """
if not isinstance(v, int):
if not is_integer_object(v):
raise ValueError("value must be an integer, received "
"{v} for {k}".format(v=type(v), k=k))
return v
Expand Down

0 comments on commit 6141754

Please sign in to comment.