Skip to content

Commit 4b9baed

Browse files
committed
Merge pull request #6659 from jreback/compress
BUG: Bug in compat with np.compress, surfaced in (GH6658)
2 parents 2e13849 + dd5d78b commit 4b9baed

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

doc/source/release.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ API Changes
126126
DataFrame returned by ``GroupBy.apply`` (:issue:`6124`). This facilitates
127127
``DataFrame.stack`` operations where the name of the column index is used as
128128
the name of the inserted column containing the pivoted data.
129-
130-
- The :func:`pivot_table`/:meth:`DataFrame.pivot_table` and :func:`crosstab` functions
131-
now take arguments ``index`` and ``columns`` instead of ``rows`` and ``cols``. A
129+
130+
- The :func:`pivot_table`/:meth:`DataFrame.pivot_table` and :func:`crosstab` functions
131+
now take arguments ``index`` and ``columns`` instead of ``rows`` and ``cols``. A
132132
``FutureWarning`` is raised to alert that the old ``rows`` and ``cols`` arguments
133133
will not be supported in a future release (:issue:`5505`)
134134

@@ -175,7 +175,7 @@ Improvements to existing features
175175
- ``StataWriter`` and ``DataFrame.to_stata`` accept time stamp and data labels (:issue:`6545`)
176176
- offset/freq info now in Timestamp __repr__ (:issue:`4553`)
177177
- Support passing ``encoding`` with xlwt (:issue:`3710`)
178-
- Performance improvement when converting ``DatetimeIndex`` to floating ordinals
178+
- Performance improvement when converting ``DatetimeIndex`` to floating ordinals
179179
using ``DatetimeConverter`` (:issue:`6636`)
180180

181181
.. _release.bug_fixes-0.14.0:
@@ -259,6 +259,7 @@ Bug Fixes
259259
- Bug in ``iloc`` indexing when positional indexer matched Int64Index of corresponding axis no reordering happened (:issue:`6612`)
260260
- Bug in ``fillna`` with ``limit`` and ``value`` specified
261261
- Bug in ``DataFrame.to_stata`` when columns have non-string names (:issue:`4558`)
262+
- Bug in compat with ``np.compress``, surfaced in (:issue:`6658`)
262263

263264
pandas 0.13.1
264265
-------------

pandas/core/series.py

+4
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ def base(self):
342342
def ravel(self, order='C'):
343343
return self.values.ravel(order=order)
344344

345+
def compress(self, condition, axis=0, out=None, **kwargs):
346+
# 1-d compat with numpy
347+
return self[condition]
348+
345349
def transpose(self):
346350
""" support for compatiblity """
347351
return self

pandas/tests/test_series.py

+9
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,15 @@ def f(x):
34363436
s = Series(np.random.randn(10))
34373437
tm.assert_almost_equal(s.ravel(order='F'),s.values.ravel(order='F'))
34383438

3439+
# compress
3440+
# GH 6658
3441+
s = Series([0,1.,-1],index=list('abc'))
3442+
result = np.compress(s>0,s)
3443+
assert_series_equal(result, Series([1.],index=['b']))
3444+
3445+
result = np.compress(s<-1,s)
3446+
assert_series_equal(result, Series([],dtype='float64'))
3447+
34393448
def test_complexx(self):
34403449

34413450
# GH4819

0 commit comments

Comments
 (0)