Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: strange behaviour of .index.min() #6027

Closed
dsm054 opened this issue Jan 21, 2014 · 1 comment
Closed

BUG: strange behaviour of .index.min() #6027

dsm054 opened this issue Jan 21, 2014 · 1 comment

Comments

@dsm054
Copy link
Contributor

dsm054 commented Jan 21, 2014

I was expecting df.index.min() here to be equal to min(df.index), and I guess it is; but I wasn't expecting this:

>>> import pandas as pd
>>> pd.__version__
'0.13.0-268-g08c1302'
>>> df = pd.DataFrame({"A": [1]})
>>> df.index
Int64Index([0], dtype='int64')
>>> min(df.index)
0
>>> type(min(df.index))
<type 'numpy.int64'>
>>> m = df.index.min()
>>> m == 0
True
>>> type(m)
<class 'pandas.core.index.Int64Index'>
>>> m
[...]
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_268_g08c1302-py2.7-linux-i686.egg/pandas/core/common.py", line 2570, in as_escaped_unicode
    result = compat.text_type(thing)  # we should try this first
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_268_g08c1302-py2.7-linux-i686.egg/pandas/core/base.py", line 201, in __unicode__
    quote_strings=True)
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_268_g08c1302-py2.7-linux-i686.egg/pandas/core/common.py", line 2597, in pprint_thing
    elif _is_sequence(thing) and _nest_lvl < \
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_268_g08c1302-py2.7-linux-i686.egg/pandas/core/common.py", line 2100, in _is_sequence
    iter(x)
RuntimeError: maximum recursion depth exceeded while calling a Python object

The same thing applies to .max().

@jreback
Copy link
Contributor

jreback commented Jan 21, 2014

this is a known issue, see #4551
basically min/max are not 'defned' correctly for index ATM (so don't use them), instead do

df.index.to_series().min()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants