Skip to content

Commit 4b639ce

Browse files
committed
TST: Test aggregation over arrays (#3788)
1 parent 02ef0a8 commit 4b639ce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_groupby.py

+17
Original file line numberDiff line numberDiff line change
@@ -6813,6 +6813,23 @@ def test_group_shift_with_null_key(self):
68136813

68146814
assert_frame_equal(result, expected)
68156815

6816+
def test_agg_over_numpy_arrays(self):
6817+
# GH 3788
6818+
df = pd.DataFrame([[1, np.array([10, 20, 30])],
6819+
[1, np.array([40, 50, 60])],
6820+
[2, np.array([20, 30, 40])]],
6821+
columns=['category', 'arraydata'])
6822+
result = df.groupby('category').agg(sum)
6823+
6824+
expected_data = [[np.array([50, 70, 90])], [np.array([20, 30, 40])]]
6825+
expected_index = pd.Index([1, 2], name='category')
6826+
expected_column = ['arraydata']
6827+
expected = pd.DataFrame(expected_data,
6828+
index=expected_index,
6829+
columns=expected_column)
6830+
6831+
assert_frame_equal(result, expected)
6832+
68166833

68176834
def assert_fp_equal(a, b):
68186835
assert (np.abs(a - b) < 1e-12).all()

0 commit comments

Comments
 (0)