squeeze works on 0 length arrays #11230

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Contributor

MaximilianR commented Oct 3, 2015

fixes: pydata#11229.
fixes: pydata#8999.

Also a better implementation that avoids ix

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

@jreback jreback commented on an outdated diff Oct 3, 2015

pandas/tests/test_generic.py
@@ -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)))
@jreback

jreback Oct 3, 2015

Contributor

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

furthermore this should preserve name

Contributor

MaximilianR commented Oct 3, 2015

@jreback tests added

Contributor

MaximilianR commented Oct 3, 2015

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

Contributor

jreback commented Oct 3, 2015

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

Contributor

MaximilianR commented Oct 3, 2015

OK @jreback, test added for that too

Contributor

TomAugspurger commented Oct 3, 2015

Also closes pydata#8999

jreback added this to the 0.17.1 milestone Oct 3, 2015

Contributor

jreback commented Oct 3, 2015

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

Contributor

MaximilianR commented Oct 4, 2015

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

@jreback jreback commented on an outdated diff Oct 5, 2015

doc/source/whatsnew/v0.17.1.txt
@@ -42,3 +42,5 @@ Performance Improvements
Bug Fixes
~~~~~~~~~
+
+- Bug in `squeeze` with zero length arrays (:issue:`11230`) & (:issue:`8999`)
@jreback

jreback Oct 5, 2015

Contributor

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

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

Contributor

MaximilianR commented Oct 5, 2015

@jreback done!

Contributor

jreback commented Oct 9, 2015

merged via aa94ae4

thanks!

jreback closed this Oct 9, 2015

MaximilianR deleted the SixtyCapital:squeeze branch Dec 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment