squeeze works on 0 length arrays by max-sixty · Pull Request #11230 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation11 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

max-sixty

fixes: #11229.
fixes: #8999.

Also a better implementation that avoids ix

Should I add to What's new for 0.17? Or is that closed now?

jreback

@@ -1717,6 +1717,10 @@ def test_squeeze(self):
p4d = tm.makePanel4D().reindex(labels=['label1'],items=['ItemA'])
tm.assert_frame_equal(p4d.squeeze(),p4d.ix['label1','ItemA'])
# don't fail with 0 length dimensions
empty=pd.DataFrame(pd.np.empty(shape=(0,1)))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with all shapes here (series.frame,etc)

furthermore this should preserve name

@max-sixty

@max-sixty

What should the behavior be here:

empty_series=pd.Series([], name='five').squeeze()

numpy returns itself:

In [18]: pd.np.empty(0) Out[18]: array([], dtype=float64)

In [19]: pd.np.empty(0).squeeze() Out[19]: array([], dtype=float64)

...which is the current pandas implementation too.
But I could see None being acceptable here

@jreback

no squeeze does not return a scalar always a Series (or high dim)

@max-sixty

@TomAugspurger

@jreback

their is a whatsnew for 0.17.1 pls add a release note.

@max-sixty

@jreback what's new added, commits squashed, ready to go from this end

jreback

@@ -42,3 +42,5 @@ Performance Improvements
Bug Fixes
~~~~~~~~~
- Bug in `squeeze` with zero length arrays (:issue:`11230`) & (:issue:`8999`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use double-backtickers (and say .squeeze())

list issues like: (:issue: 11230, :issue:8999)

@max-sixty

@max-sixty

@jreback

This was referenced

Oct 9, 2015