Skip to content

BUG: Bug in compat with np.compress, surfaced in (GH6658) #6659

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
Mar 18, 2014
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
9 changes: 5 additions & 4 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ API Changes
DataFrame returned by ``GroupBy.apply`` (:issue:`6124`). This facilitates
``DataFrame.stack`` operations where the name of the column index is used as
the name of the inserted column containing the pivoted data.
- The :func:`pivot_table`/:meth:`DataFrame.pivot_table` and :func:`crosstab` functions
now take arguments ``index`` and ``columns`` instead of ``rows`` and ``cols``. A

- The :func:`pivot_table`/:meth:`DataFrame.pivot_table` and :func:`crosstab` functions
now take arguments ``index`` and ``columns`` instead of ``rows`` and ``cols``. A
``FutureWarning`` is raised to alert that the old ``rows`` and ``cols`` arguments
will not be supported in a future release (:issue:`5505`)

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

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

pandas 0.13.1
-------------
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ def base(self):
def ravel(self, order='C'):
return self.values.ravel(order=order)

def compress(self, condition, axis=0, out=None, **kwargs):
# 1-d compat with numpy
return self[condition]

def transpose(self):
""" support for compatiblity """
return self
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,15 @@ def f(x):
s = Series(np.random.randn(10))
tm.assert_almost_equal(s.ravel(order='F'),s.values.ravel(order='F'))

# compress
# GH 6658
s = Series([0,1.,-1],index=list('abc'))
result = np.compress(s>0,s)
assert_series_equal(result, Series([1.],index=['b']))

result = np.compress(s<-1,s)
assert_series_equal(result, Series([],dtype='float64'))

def test_complexx(self):

# GH4819
Expand Down