@@ -331,25 +331,6 @@ def test_rank_dense_method(self):
331
331
expected = Series (exp ).astype (result .dtype )
332
332
assert_series_equal (result , expected )
333
333
334
- def test_rank_dense_ (self ):
335
- # GH15630, pct should be on 100% basis even when method='dense'
336
- in_out = [([1 ], [1. ]),
337
- ([2 ], [1. ]),
338
- ([0 ], [1. ]),
339
- ([2 , 2 ], [1. , 1. ]),
340
- ([1 , 2 , 3 ], [1. / 3 , 2. / 3 , 3. / 3 ]),
341
- ([4 , 2 , 1 ], [3. / 3 , 2. / 3 , 1. / 3 ],),
342
- ([1 , 1 , 5 , 5 , 3 ], [1. / 3 , 1. / 3 , 3. / 3 , 3. / 3 , 2. / 3 ]),
343
- ([- 5 , - 4 , - 3 , - 2 , - 1 ],
344
- [1. / 5 , 2. / 5 , 3. / 5 , 4. / 5 , 5. / 5 ])]
345
-
346
- for ser , exp in in_out :
347
- for dtype in dtypes :
348
- s = Series (ser ).astype (dtype )
349
- result = s .rank (method = 'dense' , pct = True )
350
- expected = Series (exp ).astype (result .dtype )
351
- assert_series_equal (result , expected )
352
-
353
334
def test_rank_descending (self ):
354
335
dtypes = ['O' , 'f8' , 'i8' ]
355
336
@@ -395,3 +376,23 @@ def test_rank_modify_inplace(self):
395
376
s .rank ()
396
377
result = s
397
378
assert_series_equal (result , expected )
379
+
380
+
381
+ @pytest .mark .parametrize ('dtype' , ['O' , 'f8' , 'i8' ])
382
+ @pytest .mark .parametrize ('ser, exp' , [
383
+ ([1 ], [1. ]),
384
+ ([2 ], [1. ]),
385
+ ([0 ], [1. ]),
386
+ ([2 , 2 ], [1. , 1. ]),
387
+ ([1 , 2 , 3 ], [1. / 3 , 2. / 3 , 3. / 3 ]),
388
+ ([4 , 2 , 1 ], [3. / 3 , 2. / 3 , 1. / 3 ],),
389
+ ([1 , 1 , 5 , 5 , 3 ], [1. / 3 , 1. / 3 , 3. / 3 , 3. / 3 , 2. / 3 ]),
390
+ ([- 5 , - 4 , - 3 , - 2 , - 1 ], [1. / 5 , 2. / 5 , 3. / 5 , 4. / 5 , 5. / 5 ])])
391
+ def test_rank_pct (dtype , ser , exp ):
392
+ # GH15630, pct should be on 100% basis even when method='dense'
393
+ # TODO: add other methods (i.e. 'average', 'min', 'max', 'first')
394
+
395
+ s = Series (ser ).astype (dtype )
396
+ result = s .rank (method = 'dense' , pct = True )
397
+ expected = Series (exp ).astype (result .dtype )
398
+ assert_series_equal (result , expected )
0 commit comments