Skip to content

Float Index Interpreted as Object dtype #5914

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

Closed
theandygross opened this issue Jan 13, 2014 · 4 comments · Fixed by #5918
Closed

Float Index Interpreted as Object dtype #5914

theandygross opened this issue Jan 13, 2014 · 4 comments · Fixed by #5918
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@theandygross
Copy link
Contributor

When I cast a FloatIndex to a numpy array, I get an array of objects. The desired behavior should be float. This is backwards incompatible with pre-FloatIndex behavior.

In [119]:   s = pd.Series([1,2,3],[1.,2.,3.])
               array(s.index).dtype

Out[119]:  dtype('O')

The Int64Index works as expected.

In [114]:    s = pd.Series([1,2,3],[1,2,3])
                array(s.index).dtype

Out[114]:  dtype('int64')
@jreback
Copy link
Contributor

jreback commented Jan 13, 2014

this is the same as 0.12

a Float64Index is actually object dtype as it makes exact matching floats easier

is their a reason you think the implementation matters here?

@theandygross
Copy link
Contributor Author

I'm running into issues where the new index is breaking code... Here is a toy example:

In [171]:

s = pd.Series([1,2,3],[1.,2.,3.])
d = pd.Series(s.index, s.index)
d.idxmax()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-171-89e600a2d902> in <module>()
      1 s = pd.Series([1,2,3],[1.,2.,3.])
      2 d = pd.Series(s.index, s.index)
----> 3 d.idxmax()

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/series.pyc in idxmax(self, axis, out, skipna)
   1276         DataFrame.idxmax
   1277         """
-> 1278         i = nanops.nanargmax(_values_from_object(self), skipna=skipna)
   1279         if i == -1:
   1280             return pa.NA

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/nanops.pyc in nanargmax(values, axis, skipna)
    373     """
    374     values, mask, dtype = _get_values(values, skipna, fill_value_typ='-inf',
--> 375                                       isfinite=True)
    376     result = values.argmax(axis)
    377     result = _maybe_arg_null_out(result, axis, mask, skipna)

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/nanops.pyc in _get_values(values, skipna, fill_value, fill_value_typ, isfinite, copy)
    139     values = _values_from_object(values)
    140     if isfinite:
--> 141         mask = _isfinite(values)
    142     else:
    143         mask = isnull(values)

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/nanops.pyc in _isfinite(values)
    172     if issubclass(values.dtype.type, (np.timedelta64, np.datetime64)):
    173         return isnull(values)
--> 174     return -np.isfinite(values)
    175 
    176 

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

@jreback
Copy link
Contributor

jreback commented Jan 13, 2014

ok let me look at that
prob a bug

@jreback
Copy link
Contributor

jreback commented Jan 13, 2014

was an issue with handling object dtypes in general in idxmin, not directly related to Float64Index...but fixed anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants