Skip to content

Commit

Permalink
Uncomment
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Dec 28, 2023
1 parent 192b080 commit 6b2bca6
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions pandas/tests/groupby/test_all_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,45 @@
import pandas._testing as tm
from pandas.tests.groupby import get_groupby_method_args

# def test_multiindex_group_all_columns_when_empty(groupby_func):
# # GH 32464
# df = DataFrame({"a": [], "b": [], "c": []}).set_index(["a", "b", "c"])
# gb = df.groupby(["a", "b", "c"], group_keys=False)
# method = getattr(gb, groupby_func)
# 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 = method(*args).index
# expected = df.index
# tm.assert_index_equal(result, expected)
def test_multiindex_group_all_columns_when_empty(groupby_func):
# GH 32464
df = DataFrame({"a": [], "b": [], "c": []}).set_index(["a", "b", "c"])
gb = df.groupby(["a", "b", "c"], group_keys=False)
method = getattr(gb, groupby_func)
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 = method(*args).index
expected = df.index
tm.assert_index_equal(result, expected)


# def test_duplicate_columns(request, groupby_func, as_index):
# # GH#50806
# if groupby_func == "corrwith":
# msg = "GH#50845 - corrwith fails when there are duplicate columns"
# request.applymarker(pytest.mark.xfail(reason=msg))
# df = DataFrame([[1, 3, 6], [1, 4, 7], [2, 5, 8]], columns=list("abb"))
# args = get_groupby_method_args(groupby_func, df)
# gb = df.groupby("a", as_index=as_index)
# 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(gb, groupby_func)(*args)
def test_duplicate_columns(request, groupby_func, as_index):
# GH#50806
if groupby_func == "corrwith":
msg = "GH#50845 - corrwith fails when there are duplicate columns"
request.applymarker(pytest.mark.xfail(reason=msg))
df = DataFrame([[1, 3, 6], [1, 4, 7], [2, 5, 8]], columns=list("abb"))
args = get_groupby_method_args(groupby_func, df)
gb = df.groupby("a", as_index=as_index)
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(gb, groupby_func)(*args)

# expected_df = df.set_axis(["a", "b", "c"], axis=1)
# expected_args = get_groupby_method_args(groupby_func, expected_df)
# expected_gb = expected_df.groupby("a", as_index=as_index)
# warn = FutureWarning if groupby_func == "fillna" else None
# warn_msg = "DataFrameGroupBy.fillna is deprecated"
# with tm.assert_produces_warning(warn, match=warn_msg):
# expected = getattr(expected_gb, groupby_func)(*expected_args)
# if groupby_func not in ("size", "ngroup", "cumcount"):
# expected = expected.rename(columns={"c": "b"})
# tm.assert_equal(result, expected)
expected_df = df.set_axis(["a", "b", "c"], axis=1)
expected_args = get_groupby_method_args(groupby_func, expected_df)
expected_gb = expected_df.groupby("a", as_index=as_index)
warn = FutureWarning if groupby_func == "fillna" else None
warn_msg = "DataFrameGroupBy.fillna is deprecated"
with tm.assert_produces_warning(warn, match=warn_msg):
expected = getattr(expected_gb, groupby_func)(*expected_args)
if groupby_func not in ("size", "ngroup", "cumcount"):
expected = expected.rename(columns={"c": "b"})
tm.assert_equal(result, expected)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 6b2bca6

Please sign in to comment.