File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -136,19 +136,6 @@ def test_basic_aggregations(dtype):
136
136
grouped .aggregate (lambda x : x * 2 )
137
137
138
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
139
def test_groupby_nonobject_dtype (multiindex_dataframe_random_data ):
153
140
key = multiindex_dataframe_random_data .index .codes [0 ]
154
141
grouped = multiindex_dataframe_random_data .groupby (key )
@@ -1209,6 +1196,21 @@ def test_groupby_complex():
1209
1196
tm .assert_series_equal (result , expected )
1210
1197
1211
1198
1199
+ def test_groupby_complex_2 ():
1200
+ df = DataFrame (
1201
+ [
1202
+ {"a" : 2 , "b" : 1 + 2j },
1203
+ {"a" : 1 , "b" : 1 + 1j },
1204
+ {"a" : 1 , "b" : 1 + 2j },
1205
+ ]
1206
+ )
1207
+ assert df .groupby ("b" ).groups == {(1 + 1j ): [1 ], (1 + 2j ): [0 , 2 ]}
1208
+ tm .assert_frame_equal (
1209
+ df .groupby ("b" ).mean (),
1210
+ DataFrame ({"a" : {(1 + 1j ): 1.0 , (1 + 2j ): 1.5 }}),
1211
+ )
1212
+
1213
+
1212
1214
def test_groupby_complex_numbers (using_infer_string ):
1213
1215
# GH 17927
1214
1216
df = DataFrame (
You can’t perform that action at this time.
0 commit comments