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

Comments

Projects
None yet
3 participants
@TomAugspurger
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 TomAugspurger added the Docs label Dec 4, 2014

@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Dec 4, 2014

Contributor

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?

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 modified the milestones: 0.16.0, Next Major Release Mar 6, 2015

@Winterflower

This comment has been minimized.

Show comment
Hide comment
@Winterflower

Winterflower Jul 20, 2015

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?

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?

@TomAugspurger

This comment has been minimized.

Show comment
Hide comment
@TomAugspurger

TomAugspurger Jul 20, 2015

Contributor

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

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).

@Winterflower

This comment has been minimized.

Show comment
Hide comment
@Winterflower

Winterflower Jul 20, 2015

Contributor

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

Contributor

Winterflower commented Jul 20, 2015

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

@TomAugspurger

This comment has been minimized.

Show comment
Hide comment
@TomAugspurger

TomAugspurger Jul 20, 2015

Contributor

Yep

Contributor

TomAugspurger commented Jul 20, 2015

Yep

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

@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Oct 9, 2015

Contributor

closed by #11230

Contributor

jreback commented Oct 9, 2015

closed by #11230

@jreback jreback closed this Oct 9, 2015

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

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, 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