Skip to content

Commit

Permalink
Move one more
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach committed Dec 5, 2023
1 parent 3bb978f commit 84128b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 25 additions & 0 deletions pandas/tests/groupby/test_all_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import pytest

import pandas as pd
from pandas import DataFrame
import pandas._testing as tm
from pandas.tests.groupby import get_groupby_method_args
Expand Down Expand Up @@ -56,3 +57,27 @@ def test_duplicate_columns(request, groupby_func, as_index):
if groupby_func not in ("size", "ngroup", "cumcount"):
expected = expected.rename(columns={"c": "b"})
tm.assert_equal(result, expected)


@pytest.mark.parametrize(
"idx",
[
pd.Index(["a", "a"], name="foo"),
pd.MultiIndex.from_tuples((("a", "a"), ("a", "a")), names=["foo", "bar"]),
],
)
def test_dup_labels_output_shape(groupby_func, idx):
if groupby_func in {"size", "ngroup", "cumcount"}:
pytest.skip(f"Not applicable for {groupby_func}")

df = DataFrame([[1, 1]], columns=idx)
grp_by = df.groupby([0])

args = get_groupby_method_args(groupby_func, df)
warn = FutureWarning if groupby_func == "fillna" else None
warn_msg = "DataFrameGroupBy.fillna is deprecated"
with tm.assert_produces_warning(warn, match=warn_msg):
result = getattr(grp_by, groupby_func)(*args)

assert result.shape == (1, 2)
tm.assert_index_equal(result.columns, idx)
25 changes: 0 additions & 25 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import pandas._testing as tm
from pandas.core.arrays import BooleanArray
import pandas.core.common as com
from pandas.tests.groupby import get_groupby_method_args

pytestmark = pytest.mark.filterwarnings("ignore:Mean of empty slice:RuntimeWarning")

Expand Down Expand Up @@ -2424,30 +2423,6 @@ def test_group_on_empty_multiindex(transformation_func, request):
tm.assert_equal(result, expected)


@pytest.mark.parametrize(
"idx",
[
Index(["a", "a"], name="foo"),
MultiIndex.from_tuples((("a", "a"), ("a", "a")), names=["foo", "bar"]),
],
)
def test_dup_labels_output_shape(groupby_func, idx):
if groupby_func in {"size", "ngroup", "cumcount"}:
pytest.skip(f"Not applicable for {groupby_func}")

df = DataFrame([[1, 1]], columns=idx)
grp_by = df.groupby([0])

args = get_groupby_method_args(groupby_func, df)
warn = FutureWarning if groupby_func == "fillna" else None
warn_msg = "DataFrameGroupBy.fillna is deprecated"
with tm.assert_produces_warning(warn, match=warn_msg):
result = getattr(grp_by, groupby_func)(*args)

assert result.shape == (1, 2)
tm.assert_index_equal(result.columns, idx)


def test_groupby_crash_on_nunique(axis):
# Fix following 30253
dti = date_range("2016-01-01", periods=2, name="foo")
Expand Down

0 comments on commit 84128b9

Please sign in to comment.