@@ -311,9 +311,10 @@ def test_value_counts(self, index_or_series_obj):
311
311
if isinstance (obj , pd .MultiIndex ):
312
312
expected .index = pd .Index (expected .index )
313
313
314
- # sort_index to avoid switched order when values share the same count
315
- result = result .sort_index ()
316
- expected = expected .sort_index ()
314
+ # TODO: Order of entries with the same count is inconsistent on CI (gh-32449)
315
+ if obj .duplicated ().any ():
316
+ result = result .sort_index ()
317
+ expected = expected .sort_index ()
317
318
tm .assert_series_equal (result , expected )
318
319
319
320
@pytest .mark .parametrize ("null_obj" , [np .nan , None ])
@@ -344,13 +345,26 @@ def test_value_counts_null(self, null_obj, index_or_series_obj):
344
345
expected = pd .Series (dict (counter .most_common ()), dtype = np .int64 )
345
346
expected .index = expected .index .astype (obj .dtype )
346
347
347
- tm .assert_series_equal (obj .value_counts (), expected )
348
+ result = obj .value_counts ()
349
+ if obj .duplicated ().any ():
350
+ # TODO:
351
+ # Order of entries with the same count is inconsistent on CI (gh-32449)
352
+ expected = expected .sort_index ()
353
+ result = result .sort_index ()
354
+ tm .assert_series_equal (result , expected )
348
355
349
356
# can't use expected[null_obj] = 3 as
350
357
# IntervalIndex doesn't allow assignment
351
358
new_entry = pd .Series ({np .nan : 3 }, dtype = np .int64 )
352
359
expected = expected .append (new_entry )
353
- tm .assert_series_equal (obj .value_counts (dropna = False ), expected )
360
+
361
+ result = obj .value_counts (dropna = False )
362
+ if obj .duplicated ().any ():
363
+ # TODO:
364
+ # Order of entries with the same count is inconsistent on CI (gh-32449)
365
+ expected = expected .sort_index ()
366
+ result = result .sort_index ()
367
+ tm .assert_series_equal (result , expected )
354
368
355
369
def test_value_counts_inferred (self , index_or_series ):
356
370
klass = index_or_series
0 commit comments