@@ -962,51 +962,41 @@ 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_single_occurance (self ):
965
+ @pytest .mark .parametrize ("sort" ,
966
+ [pytest .param (True , marks = pytest .mark .xfail ), False ])
967
+ @pytest .mark .parametrize ("ascending" , [True , False ])
968
+ def test_value_counts_single_occurance (self , sort , ascending ):
966
969
# GH 12679
967
970
# All items occour exactly once.
968
971
# No matter if sorted or not, the resulting values should be in
969
972
# the same order.
970
- s = Series (list ('bacdef' ))
973
+ expected = Series (list ('bacdef' ))
971
974
972
975
# Guarantee the same index if value_counts(sort=False) is used
973
- vc = s .value_counts (sort = False , ascending = False )
974
- tm .assert_series_equal (Series (vc .index ), s )
975
- vc = s .value_counts (sort = False , ascending = True )
976
- tm .assert_series_equal (Series (vc .index ), s )
976
+ vc = expected .value_counts (sort = sort , ascending = ascending )
977
+ result = Series (vc .index )
978
+ tm .assert_series_equal (result , expected )
977
979
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 )
987
-
988
- def test_value_counts_nonsorted_double_occurance (self ):
980
+ @pytest .mark .parametrize ("ascending" , [True , False ])
981
+ def test_value_counts_nonsorted_double_occurance (self , ascending ):
989
982
# GH 12679
990
983
# 'a' is there twice. Sorted, it should be there at the top.
991
984
s = Series (list ('bacaef' ))
992
- ref_nonsorted = Series (list ('bacef' ))
985
+ expected = Series (list ('bacef' ))
993
986
994
- # Guarantee the same index if value_counts(sort=False) is used
995
- vc = s .value_counts (sort = False , ascending = False )
996
- tm .assert_series_equal (Series (vc .index ), ref_nonsorted )
997
- vc = s .value_counts (sort = False , ascending = True )
998
- tm .assert_series_equal (Series (vc .index ), ref_nonsorted )
987
+ vc = s .value_counts (sort = False , ascending = ascending )
988
+ result = Series (vc .index )
989
+ tm .assert_series_equal (result , expected )
999
990
991
+ @pytest .mark .parametrize ("ascending, expected" ,
992
+ [(True , Series (list ('abcef' ))),
993
+ (False , Series (list ('bcefa' )))])
1000
994
@pytest .mark .xfail (reason = "sort=True does not guarantee the same order" )
1001
- def test_value_counts_sorted_double_occurance (self ):
995
+ def test_value_counts_sorted_double_occurance (self , ascending , expected ):
1002
996
# GH 12679
1003
997
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 )
998
+ vc = s .value_counts (sort = True , ascending = ascending )
999
+ tm .assert_series_equal (Series (vc .index ), expected )
1010
1000
1011
1001
1012
1002
class TestDuplicated (object ):
0 commit comments