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

BUG: DataFrame reductions inconsistent with Series counterparts #37827

Merged
merged 13 commits into from
Nov 14, 2020

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Nov 14, 2020

@jreback jreback added Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply Reduction Operations sum, mean, min, max, etc. labels Nov 14, 2020
@jreback jreback added this to the 1.2 milestone Nov 14, 2020
@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

#28948 is an incorrect ref (top of PR)

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

doc comments & there is an oncorrect ref to #28948

A 1.0
dtype: float64

*New behavior*:
Copy link
Contributor

Choose a reason for hiding this comment

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

needs to be an ipython block & remove the prompts

A True
dtype: bool

*New behavior*:
Copy link
Contributor

Choose a reason for hiding this comment

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

make an ipython block & remove the prompts

@@ -513,8 +516,14 @@ def make_a_block(nv, ref_loc):
v = new_values[i]

# need a new block
if m.any():
nv = f(m, v, i)
if m.any() or m.size == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment here on what is going on

# Double-check the Series behavior is to raise
with pytest.raises(TypeError, match="does not implement reduction"):
getattr(ser, method)()
with pytest.raises(TypeError, match="does not implement reduction"):
Copy link
Contributor

Choose a reason for hiding this comment

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

blank line here

# Double-check the Series behavior
with pytest.raises(TypeError, match="is not ordered for operation"):
getattr(ser, method)()
with pytest.raises(TypeError, match="is not ordered for operation"):
Copy link
Contributor

Choose a reason for hiding this comment

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

blank line

@@ -284,6 +284,58 @@ of columns could result in a larger :class:`Series` result. See (:issue:`37799`)
In [6]: df[["B", "C"]].all(bool_only=True)


Other :class:`DataFrame` reductions with ``numeric_only=None`` will also avoid
this pathological behavior (:issue:`37827`):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make sure to list all the issues you are closing the OP (3?)


*New behavior*:

.. code-block:: ipython
Copy link
Contributor

Choose a reason for hiding this comment

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

needs to be an ipython block to render

Copy link
Member Author

Choose a reason for hiding this comment

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

dangit, i thought i had copied from the previous reduction PR, was so proud of myself

Copy link
Contributor

Choose a reason for hiding this comment

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

haha


*New behavior*:

.. code-block:: ipython
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@jreback jreback added Categorical Categorical Data Type API - Consistency Internal Consistency of API/Behavior labels Nov 14, 2020
@jreback jreback merged commit 50ae0bf into pandas-dev:master Nov 14, 2020
@jbrockmendel jbrockmendel deleted the bug-reduce branch November 14, 2020 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Categorical Categorical Data Type Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply Reduction Operations sum, mean, min, max, etc.
Projects
None yet
2 participants