Skip to content

Commit e9e4489

Browse files
added sort_index to fix flaky tests
1 parent f2a4ac6 commit e9e4489

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/tests/base/test_ops.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,14 @@ def test_value_counts(self, index_or_series_obj):
251251
result = obj.value_counts()
252252

253253
counter = collections.Counter(obj)
254-
expected = pd.Series(dict(counter.most_common()), dtype=int)
254+
expected = pd.Series(dict(counter.most_common()), dtype=np.int64)
255255
expected.index = expected.index.astype(obj.dtype)
256256
if isinstance(obj, pd.MultiIndex):
257257
expected.index = pd.Index(expected.index)
258+
259+
# sort_index to avoid switched order when values share the same count
260+
result = result.sort_index()
261+
expected = expected.sort_index()
258262
tm.assert_series_equal(result, expected)
259263

260264
@pytest.mark.parametrize("null_obj", [np.nan, None])

0 commit comments

Comments
 (0)