@@ -962,41 +962,51 @@ def test_value_counts_uint64(self):
962
962
if not compat .is_platform_32bit ():
963
963
tm .assert_series_equal (result , expected )
964
964
965
- def test_value_counts_nonsorted (self ):
965
+ def test_value_counts_nonsorted_single_occurance (self ):
966
+ # GH 12679
966
967
# All items occour exactly once.
967
968
# No matter if sorted or not, the resulting values should be in
968
969
# the same order.
969
970
s = Series (list ('bacdef' ))
970
971
971
- # Garantee the same index if value_counts(sort=False) is used
972
+ # Guarantee the same index if value_counts(sort=False) is used
972
973
vc = s .value_counts (sort = False , ascending = False )
973
974
tm .assert_series_equal (Series (vc .index ), s )
974
975
vc = s .value_counts (sort = False , ascending = True )
975
976
tm .assert_series_equal (Series (vc .index ), s )
976
977
977
- # Garantee does not hold yet for the sort=True case
978
- # vc = s.value_counts(sort=True, ascending=False)
979
- # tm.assert_series_equal(Series(vc.index), s)
980
- # vc = s.value_counts(sort=True, ascending=True)
981
- # tm.assert_series_equal(Series(vc.index), s)
978
+ @pytest .mark .xfail (reason = "sort=True does not guarantee the same order" )
979
+ def test_value_counts_sorted_single_occurance (self ):
980
+ # GH 12679
981
+ s = Series (list ('bacdef' ))
982
+ # Guarantee does not hold yet for the sort=True case
983
+ vc = s .value_counts (sort = True , ascending = False )
984
+ tm .assert_series_equal (Series (vc .index ), s )
985
+ vc = s .value_counts (sort = True , ascending = True )
986
+ tm .assert_series_equal (Series (vc .index ), s )
982
987
988
+ def test_value_counts_nonsorted_double_occurance (self ):
989
+ # GH 12679
983
990
# 'a' is there twice. Sorted, it should be there at the top.
984
- # Unsorted it should stay where it is.
985
991
s = Series (list ('bacaef' ))
986
992
ref_nonsorted = Series (list ('bacef' ))
987
- ref_sorted = Series (list ('abcef' ))
988
993
989
- # Garantee the same index if value_counts(sort=False) is used
994
+ # Guarantee the same index if value_counts(sort=False) is used
990
995
vc = s .value_counts (sort = False , ascending = False )
991
996
tm .assert_series_equal (Series (vc .index ), ref_nonsorted )
992
997
vc = s .value_counts (sort = False , ascending = True )
993
998
tm .assert_series_equal (Series (vc .index ), ref_nonsorted )
994
999
995
- # Garantee does not hold yet for the sort=True case
996
- # vc = s.value_counts(sort=True, ascending=False)
997
- # tm.assert_series_equal(Series(vc.index), ref_sorted)
998
- # vc = s.value_counts(sort=True, ascending=True)
999
- # tm.assert_series_equal(Series(vc.index), ref_sorted)
1000
+ @pytest .mark .xfail (reason = "sort=True does not guarantee the same order" )
1001
+ def test_value_counts_sorted_double_occurance (self ):
1002
+ # GH 12679
1003
+ s = Series (list ('bacaef' ))
1004
+ ref_sorted = Series (list ('abcef' ))
1005
+ # Guarantee does not hold yet for the sort=True case
1006
+ vc = s .value_counts (sort = True , ascending = False )
1007
+ tm .assert_series_equal (Series (vc .index ), ref_sorted )
1008
+ vc = s .value_counts (sort = True , ascending = True )
1009
+ tm .assert_series_equal (Series (vc .index ), ref_sorted )
1000
1010
1001
1011
1002
1012
class TestDuplicated (object ):
0 commit comments