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

ValueError when slicing with NaN values #953

Closed
jcreixell opened this issue Mar 22, 2012 · 2 comments

Comments

@jcreixell
Copy link

commented Mar 22, 2012

this didn't fail before:

In [30]: a = DataFrame([[1,2,3],['b',None,'a'],[1,'b',9]])

In [31]: a
Out[31]:
0 1 2
0 1 2 3
1 b None a
2 1 b 9

In [32]: a[a[1]=='a']

ValueError Traceback (most recent call last)
/Users/jorge/ in ()
----> 1 a[a[1]=='a']

/Users/jorge/.python_unstable/lib/python2.7/site-packages/pandas-0.7.2-py2.7-macosx-10.7-intel.egg/pandas/core/frame.pyc in getitem(self, key)
1422
1423 # also raises Exception if object array with NA values

-> 1424 if com._is_bool_indexer(key):
1425 key = np.asarray(key, dtype=bool)
1426 return self._getitem_array(key)

/Users/jorge/.python_unstable/lib/python2.7/site-packages/pandas-0.7.2-py2.7-macosx-10.7-intel.egg/pandas/core/common.pyc in _is_bool_indexer(key)
321 if not lib.is_bool_array(key):
322 if isnull(key).any():
--> 323 raise ValueError('cannot index with vector containing '
324 'NA / NaN values')
325 return False

ValueError: cannot index with vector containing NA / NaN values

Note: With integer values the exception is not raised:

In [34]: a = DataFrame([[1,2,3],['b',None,'a'],[1,2,9]])

In [35]: a
Out[35]:
0 1 2
0 1 2 3
1 b NaN a
2 1 2 9

In [36]: a[a[1]=='a']
Out[36]:
Empty DataFrame
Columns: array([0, 1, 2])
Index: array([], dtype=int64)

@adamklein

This comment has been minimized.

Copy link
Contributor

commented Mar 22, 2012

Similar issue to #933

@wesm

This comment has been minimized.

Copy link
Member

commented Apr 9, 2012

This is fixed in master now, will be part of 0.7.3 release

@wesm wesm closed this Apr 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.