Skip to content
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

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

Closed
TomAugspurger opened this issue Dec 4, 2014 · 6 comments
Closed
Labels
API Design Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@TomAugspurger
Copy link
Contributor

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.

@jreback
Copy link
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 jreback added this to the 0.16.0 milestone Dec 4, 2014
@jreback jreback added API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 4, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@Winterflower
Copy link
Contributor

@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?

@TomAugspurger
Copy link
Contributor Author

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

@Winterflower
Copy link
Contributor

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

@TomAugspurger
Copy link
Contributor Author

Yep

@jreback jreback modified the milestones: 0.17.1, Next Major Release Oct 3, 2015
@jreback
Copy link
Contributor

jreback commented Oct 9, 2015

closed by #11230

@jreback jreback closed this as completed Oct 9, 2015
yarikoptic added a commit to neurodebian/pandas that referenced this issue Oct 11, 2015
* commit 'v0.17.0-8-gcac4ad2': (57 commits)
  BUG: to_excel duplicate columns
  BUG: HDFStore.append with encoded string itemsize, pandas-dev#11234
  BUG: remove midrule in latex output with header=False
  BUG: squeeze works on 0 length arrays, pandas-dev#11299, pandas-dev#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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants