Skip to content

REGR: Regression in .clip with tz-aware datetimes #11838 #11850

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
Dec 16, 2015
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
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ In addition, ``.round()`` will be available thru the ``.dt`` accessor of ``Serie
Backwards incompatible API changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The parameter ``out`` has been removed from the ``Series.round()`` method. (:issue:`11763`)
- The parameter ``out`` has been removed from the ``Series.round()`` method. (:issue:`11763`)

Bug in QuarterBegin with n=0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -189,7 +189,7 @@ Bug Fixes

- Bug in ``GroupBy.size`` when data-frame is empty. (:issue:`11699`)
- Bug in ``Period.end_time`` when a multiple of time period is requested (:issue:`11738`)

- Regression in ``.clip`` with tz-aware datetimes (:issue:`11838`)



Expand Down
4 changes: 0 additions & 4 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,6 @@ def func(cond, values, other):
result = func(cond, values, other)
if self._can_hold_na or self.ndim == 1:

if not isinstance(result, np.ndarray):
raise TypeError('Could not compare [%s] with block values'
% repr(other))

if transpose:
result = result.T

Expand Down
24 changes: 21 additions & 3 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3008,16 +3008,16 @@ def test_round(self):
name='ts')
assert_series_equal(result, expected)
self.assertEqual(result.name, self.ts.name)

def test_built_in_round(self):
if not compat.PY3:
raise nose.SkipTest('build in round cannot be overriden prior to Python 3')

s = Series([1.123, 2.123, 3.123], index=lrange(3))
result = round(s)
expected_rounded0 = Series([1., 2., 3.], index=lrange(3))
self.assert_series_equal(result, expected_rounded0)

decimals = 2
expected_rounded = Series([1.12, 2.12, 3.12], index=lrange(3))
result = round(s, decimals)
Expand Down Expand Up @@ -5844,6 +5844,24 @@ def test_clip_against_series(self):
assert_series_equal(s.clip(lower, upper), Series([1.0, 2.0, 3.5]))
assert_series_equal(s.clip(1.5, upper), Series([1.5, 1.5, 3.5]))


def test_clip_with_datetimes(self):

# GH 11838
# naive and tz-aware datetimes

t = Timestamp('2015-12-01 09:30:30')
s = Series([ Timestamp('2015-12-01 09:30:00'), Timestamp('2015-12-01 09:31:00') ])
result = s.clip(upper=t)
expected = Series([ Timestamp('2015-12-01 09:30:00'), Timestamp('2015-12-01 09:30:30') ])
assert_series_equal(result, expected)

t = Timestamp('2015-12-01 09:30:30', tz='US/Eastern')
s = Series([ Timestamp('2015-12-01 09:30:00', tz='US/Eastern'), Timestamp('2015-12-01 09:31:00', tz='US/Eastern') ])
result = s.clip(upper=t)
expected = Series([ Timestamp('2015-12-01 09:30:00', tz='US/Eastern'), Timestamp('2015-12-01 09:30:30', tz='US/Eastern') ])
assert_series_equal(result, expected)

def test_valid(self):
ts = self.ts.copy()
ts[::2] = np.NaN
Expand Down