@@ -287,25 +287,6 @@ def test_rank_dense_method(self):
287287 expected = Series (exp ).astype (result .dtype )
288288 assert_series_equal (result , expected )
289289
290- def test_rank_dense_ (self ):
291- # GH15630, pct should be on 100% basis even when method='dense'
292- in_out = [([1 ], [1. ]),
293- ([2 ], [1. ]),
294- ([0 ], [1. ]),
295- ([2 , 2 ], [1. , 1. ]),
296- ([1 , 2 , 3 ], [1. / 3 , 2. / 3 , 3. / 3 ]),
297- ([4 , 2 , 1 ], [3. / 3 , 2. / 3 , 1. / 3 ],),
298- ([1 , 1 , 5 , 5 , 3 ], [1. / 3 , 1. / 3 , 3. / 3 , 3. / 3 , 2. / 3 ]),
299- ([- 5 , - 4 , - 3 , - 2 , - 1 ],
300- [1. / 5 , 2. / 5 , 3. / 5 , 4. / 5 , 5. / 5 ])]
301-
302- for ser , exp in in_out :
303- for dtype in dtypes :
304- s = Series (ser ).astype (dtype )
305- result = s .rank (method = 'dense' , pct = True )
306- expected = Series (exp ).astype (result .dtype )
307- assert_series_equal (result , expected )
308-
309290 def test_rank_descending (self ):
310291 dtypes = ['O' , 'f8' , 'i8' ]
311292
@@ -341,3 +322,23 @@ def test_rank_object_bug(self):
341322 # smoke tests
342323 Series ([np .nan ] * 32 ).astype (object ).rank (ascending = True )
343324 Series ([np .nan ] * 32 ).astype (object ).rank (ascending = False )
325+
326+
327+ @pytest .mark .parametrize ('dtype' , ['O' , 'f8' , 'i8' ])
328+ @pytest .mark .parametrize ('ser, exp' , [
329+ ([1 ], [1. ]),
330+ ([2 ], [1. ]),
331+ ([0 ], [1. ]),
332+ ([2 , 2 ], [1. , 1. ]),
333+ ([1 , 2 , 3 ], [1. / 3 , 2. / 3 , 3. / 3 ]),
334+ ([4 , 2 , 1 ], [3. / 3 , 2. / 3 , 1. / 3 ],),
335+ ([1 , 1 , 5 , 5 , 3 ], [1. / 3 , 1. / 3 , 3. / 3 , 3. / 3 , 2. / 3 ]),
336+ ([- 5 , - 4 , - 3 , - 2 , - 1 ], [1. / 5 , 2. / 5 , 3. / 5 , 4. / 5 , 5. / 5 ])])
337+ def test_rank_pct (dtype , ser , exp ):
338+ # GH15630, pct should be on 100% basis even when method='dense'
339+ # TODO: add other methods (i.e. 'average', 'min', 'max', 'first')
340+
341+ s = Series (ser ).astype (dtype )
342+ result = s .rank (method = 'dense' , pct = True )
343+ expected = Series (exp ).astype (result .dtype )
344+ assert_series_equal (result , expected )
0 commit comments