We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ac340e commit e917385Copy full SHA for e917385
pandas/tests/groupby/test_groupby.py
@@ -136,6 +136,19 @@ def test_basic_aggregations(dtype):
136
grouped.aggregate(lambda x: x * 2)
137
138
139
+def test_groupby_complex_numbers():
140
+ df = DataFrame([
141
+ {"a": 2, "b": 1 + 2j},
142
+ {"a": 1, "b": 1 + 1j},
143
+ {"a": 1, "b": 1 + 2j},
144
+ ])
145
+ assert df.groupby("b").groups == {(1 + 1j): [1], (1 + 2j): [0, 2]}
146
+ tm.assert_frame_equal(
147
+ df.groupby("b").mean(),
148
+ DataFrame({"a": {(1 + 1j): 1.0, (1 + 2j): 1.5}}),
149
+ )
150
+
151
152
def test_groupby_nonobject_dtype(multiindex_dataframe_random_data):
153
key = multiindex_dataframe_random_data.index.codes[0]
154
grouped = multiindex_dataframe_random_data.groupby(key)
0 commit comments