DOC: Surprising behavior on DataFrame.squeeze() with 0 or 1 col/row #8999

Closed
TomAugspurger opened this Issue Dec 4, 2014 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

TomAugspurger commented Dec 4, 2014

pd.DataFrame({"A": [1]}).squeeze()  # -> 1
pd.DataFrame({"A": []}).squeeze()  # Noop

The second one is genuinely surprising; I would have expected it to return an empty Series with the name set to A. But it is consisent with numpy (np.array([[], []]).squeeze()) so I've marked is as a doc issue.

TomAugspurger added the Docs label Dec 4, 2014

Contributor

jreback commented Dec 4, 2014

hmm, not sure if this is intuitve. I agree in that it should return an empty series. This is prob not tested at all. Maybe change and see if anything affected?

jreback added this to the 0.16.0 milestone Dec 4, 2014

@jreback jreback modified the milestone: 0.16.0, Next Major Release Mar 6, 2015

Contributor

Winterflower commented Jul 20, 2015

@TomAugspurger just testing this issue with pandas version 0.16.2 and I get an empty DataFrame when I do

df = pd.DataFrame({'A':[]})
print df.squeeze()

>>>
Empty DataFrame
Columns: [A]
Index: []

Is this what you meant by Noop?

Contributor

TomAugspurger commented Jul 20, 2015

Sorry yeah, I should have been clearer. I meant the output was the same as the input (an Empty DataFrame).

Contributor

Winterflower commented Jul 20, 2015

Ah ok, you meant Noop as in no-operation.

Contributor

TomAugspurger commented Jul 20, 2015

Yep

@jreback jreback modified the milestone: 0.17.1, Next Major Release Oct 3, 2015

Contributor

jreback commented Oct 9, 2015

closed by #11230

jreback closed this Oct 9, 2015

@yarikoptic yarikoptic added a commit to neurodebian/pandas that referenced this issue Oct 11, 2015

@yarikoptic yarikoptic Merge commit 'v0.17.0-8-gcac4ad2' into debian
* commit 'v0.17.0-8-gcac4ad2': (57 commits)
  BUG: to_excel duplicate columns
  BUG: HDFStore.append with encoded string itemsize, #11234
  BUG: remove midrule in latex output with header=False
  BUG: squeeze works on 0 length arrays, #11299, #8999
  DOC: add whatsnew 0.17.1 to index
  DOC: update resample docs
  timeseries: add tip about using groupby() rather than resample
  DOC: release_stats.sh script to report release stats
  DOC: edit release.rst
  CI: fix numpy to 1.9.3 in 2.7,3.5 builds for now, as packages for 1.10.0 not released ATM
  DOC: Included halflife as one 3 optional params that must be specified
  DOC: whatsnew 0.17.0 edits
  BUG/ERR: raise when trying to set a subset of values in a datetime64[ns, tz] column with another tz
  DOC: Add note about unicode layout
  DOC: hack to numpydoc to include attributes that are None (GH6100)
  DOC: add str accessor docstring pages to api.rst to avoid warning
  DOC: hack to numpydoc to avoid warnings for Categorical (not including members)
  skip some plotting tests if scipy is not installed
  add matplotlib to ci for 3.5
  COMPAT/PERF: lib.ismember_int64 on older numpies/cython not comparing correctly PERF: use np.in1d on larger isin sizes
  ...
cd7c38b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment