Skip to content

COMPAT: py2.7 compat for Timestamp.replace #15030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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