Closed
Description
e.g https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=15921
================================== FAILURES ===================================
______________________________ test_apply[True] _______________________________
[gw1] win32 -- Python 3.7.4 C:\Miniconda\envs\pandas-dev\python.exe
ordered = True
@pytest.mark.parametrize("ordered", [True, False])
def test_apply(ordered):
# GH 10138
dense = Categorical(list("abc"), ordered=ordered)
# 'b' is in the categories but not in the list
missing = Categorical(list("aaa"), categories=["a", "b"], ordered=ordered)
values = np.arange(len(dense))
df = DataFrame({"missing": missing, "dense": dense, "values": values})
grouped = df.groupby(["missing", "dense"], observed=True)
# missing category 'b' should still exist in the output index
idx = MultiIndex.from_arrays([missing, dense], names=["missing", "dense"])
expected = DataFrame([0, 1, 2.0], index=idx, columns=["values"])
result = grouped.apply(lambda x: np.mean(x))
> assert_frame_equal(result, expected)
E AssertionError: DataFrame are different
E
E DataFrame shape mismatch
E [left]: (3, 3)
E [right]: (3, 1)
pandas\tests\groupby\test_categorical.py:228: AssertionError
______________________________ test_apply[False] ______________________________
[gw1] win32 -- Python 3.7.4 C:\Miniconda\envs\pandas-dev\python.exe
ordered = False
@pytest.mark.parametrize("ordered", [True, False])
def test_apply(ordered):
# GH 10138
dense = Categorical(list("abc"), ordered=ordered)
# 'b' is in the categories but not in the list
missing = Categorical(list("aaa"), categories=["a", "b"], ordered=ordered)
values = np.arange(len(dense))
df = DataFrame({"missing": missing, "dense": dense, "values": values})
grouped = df.groupby(["missing", "dense"], observed=True)
# missing category 'b' should still exist in the output index
idx = MultiIndex.from_arrays([missing, dense], names=["missing", "dense"])
expected = DataFrame([0, 1, 2.0], index=idx, columns=["values"])
result = grouped.apply(lambda x: np.mean(x))
> assert_frame_equal(result, expected)
E AssertionError: DataFrame are different
E
E DataFrame shape mismatch
E [left]: (3, 3)
E [right]: (3, 1)
pandas\tests\groupby\test_categorical.py:228: AssertionError
Metadata
Metadata
Assignees
Labels
No labels