CLN: Moving Series.rank and DataFrame.rank to generic.py
State: closed

I'm pulling this out from PR #11918. It is a first step toward solving issue #11759

The signature of `Series.rank` changes, and is now the same as `DataFrame.rank`. This may cause some problems...


Labels:
name: API Design
name: Clean

Comments:
need a whatsnew entry to explain this change (can be pretty short, just demonstrating the old/new)

Is it ok like that?

I've changed the error message, and removed the check for `Series`.

can you rebase/update

@jorisvandenbossche i've changed the docstring as you suggested, and added a test to check if `.rank(axis=0)` and `.rank(axis='index')` on the one hand, and `.rank(axis=1)` and `.rank(axis='columns')` on the other hand, are equivalent.

Uh?

```
ERROR: test_get_underlying_price (pandas.io.tests.test_data.TestYahooOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/util/testing.py", line 1831, in wrapper
    return t(*args, **kwargs)
  File "/home/travis/build/pydata/pandas/pandas/io/tests/test_data.py", line 402, in test_get_underlying_price
    quote_price = options_object._underlying_price_from_root(root)
  File "/home/travis/build/pydata/pandas/pandas/io/data.py", line 739, in _underlying_price_from_root
    underlying_price = root.xpath('.//*[@class="time_rtq_ticker Fz-30 Fw-b"]')[0]\
IndexError: list index out of range
```

I don't understand.

The same error appeared in the pull request #11582. Is it me, or is this another issue?

neh, just back network connectivity with Travis, ignore / try again

It's my lucky day

```
======================================================================
ERROR: test_get_goog_volume (pandas.io.tests.test_data.TestGoogle)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/indexes/base.py", line 1900, in get_value
    return tslib.get_value_box(s, key)
  File "pandas/tslib.pyx", line 807, in pandas.tslib.get_value_box (pandas/tslib.c:17638)
    cpdef object get_value_box(ndarray arr, object loc):
  File "pandas/tslib.pyx", line 816, in pandas.tslib.get_value_box (pandas/tslib.c:17306)
    i = <Py_ssize_t> loc
TypeError: 'str' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/tseries/index.py", line 1344, in get_value
    return _maybe_box(self, Index.get_value(self, series, key),
  File "/home/travis/build/pydata/pandas/pandas/indexes/base.py", line 1908, in get_value
    raise e1
  File "/home/travis/build/pydata/pandas/pandas/indexes/base.py", line 1894, in get_value
    return self._engine.get_value(s, k)
  File "pandas/index.pyx", line 103, in pandas.index.IndexEngine.get_value (pandas/index.c:3204)
    cpdef get_value(self, ndarray arr, object key):
  File "pandas/index.pyx", line 111, in pandas.index.IndexEngine.get_value (pandas/index.c:2903)
    loc = self.get_loc(key)
  File "pandas/index.pyx", line 575, in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10977)
    self._date_check_type(val)
  File "pandas/index.pyx", line 581, in pandas.index.DatetimeEngine._date_check_type (pandas/index.c:11145)
    raise KeyError(val)
KeyError: 'JAN-02-2015'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pandas/index.pyx", line 565, in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10766)
    return self.mapping.get_item(val.value)
  File "pandas/hashtable.pyx", line 303, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6527)
    cpdef get_item(self, int64_t val):
  File "pandas/hashtable.pyx", line 309, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6465)
    raise KeyError(val)
KeyError: 1420156800000000000

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/tseries/index.py", line 1354, in get_value
    return self.get_value_maybe_box(series, key)
  File "/home/travis/build/pydata/pandas/pandas/tseries/index.py", line 1364, in get_value_maybe_box
    values = self._engine.get_value(_values_from_object(series), key)
  File "pandas/index.pyx", line 103, in pandas.index.IndexEngine.get_value (pandas/index.c:3204)
    cpdef get_value(self, ndarray arr, object key):
  File "pandas/index.pyx", line 111, in pandas.index.IndexEngine.get_value (pandas/index.c:2903)
    loc = self.get_loc(key)
  File "pandas/index.pyx", line 567, in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10832)
    raise KeyError(val)
KeyError: Timestamp('2015-01-02 00:00:00')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/util/testing.py", line 1831, in wrapper
    return t(*args, **kwargs)
  File "/home/travis/build/pydata/pandas/pandas/io/tests/test_data.py", line 93, in test_get_goog_volume
    self.assertEqual(df.Volume.ix['JAN-02-2015'], 1446662)
  File "/home/travis/build/pydata/pandas/pandas/core/indexing.py", line 77, in __getitem__
    return self._getitem_axis(key, axis=0)
  File "/home/travis/build/pydata/pandas/pandas/core/indexing.py", line 993, in _getitem_axis
    return self._get_label(key, axis=axis)
  File "/home/travis/build/pydata/pandas/pandas/core/indexing.py", line 88, in _get_label
    return self.obj[label]
  File "/home/travis/build/pydata/pandas/pandas/core/series.py", line 558, in __getitem__
    result = self.index.get_value(self, key)
  File "/home/travis/build/pydata/pandas/pandas/tseries/index.py", line 1356, in get_value
    raise KeyError(key)
KeyError: 'JAN-02-2015'
----------------------------------------------------------------------
Ran 9254 tests in 337.827s
FAILED (SKIP=152, errors=1)
```

I must have jumped in a parallel universe at some point, the tests used to have failed...

@jreback all green now

sorry, no parallel universe, I just restarted the test .. :-) 
Maybe time to remove those data tests

minor comments. ping when pushed and green.

All green

thanks!