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

dataframe slice assignment failure #881

Closed
adamklein opened this issue Mar 8, 2012 · 0 comments
Closed

dataframe slice assignment failure #881

adamklein opened this issue Mar 8, 2012 · 0 comments
Assignees
Labels
Milestone

Comments

@adamklein
Copy link
Contributor

In [27]: df
Out[27]: 
   a         b         c   d
0  2  0.103795 -0.066523 NaN
1  3 -0.939895 -0.208760 NaN
2  9  1.968456  0.419374 NaN
3  6 -0.105170  0.162064 NaN
4  7  0.381707  2.126133 NaN

In [28]: df[df['a']==3]
Out[28]: 
   a         b        c   d
1  3 -0.939895 -0.20876 NaN

In [29]: df[df['a']==2]
Out[29]: 
   a         b         c   d
0  2  0.103795 -0.066523 NaN

In [30]: df[df['a']==2] = 100
---------------------------------------------------------------------------
IndexingError                             Traceback (most recent call last)
/home/adam/code/pandas/<ipython-input-30-f7da2453a9f6> in <module>()
----> 1 df[df['a']==2] = 100

/home/adam/code/pandas/pandas/core/frame.py in __setitem__(self, key, value)
   1491             self._boolean_set(key, value)
   1492         elif isinstance(key, (np.ndarray, list)):
-> 1493             return self._set_item_multiple(key, value)
   1494         else:
   1495             # set column


/home/adam/code/pandas/pandas/core/frame.py in _set_item_multiple(self, keys, value)
   1516                 self[k1] = value[k2]
   1517         else:
-> 1518             self.ix[:, keys] = value
   1519 
   1520     def _set_item(self, key, value):

/home/adam/code/pandas/pandas/core/indexing.py in __setitem__(self, key, value)
     59                 raise IndexingError('only tuples of length <= %d supported',
     60                                     self.ndim)
---> 61             indexer = self._convert_tuple(key)
     62         else:
     63             indexer = self._convert_to_indexer(key)

/home/adam/code/pandas/pandas/core/indexing.py in _convert_tuple(self, key)
     68         keyidx = []
     69         for i, k in enumerate(key):
---> 70             idx = self._convert_to_indexer(k, axis=i)
     71             keyidx.append(idx)
     72         return tuple(keyidx)

/home/adam/code/pandas/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis)
    282         elif _is_list_like(obj):
    283             if com._is_bool_indexer(obj):
--> 284                 objarr = _check_bool_indexer(labels, obj)
    285                 return objarr
    286             else:

/home/adam/code/pandas/pandas/core/indexing.py in _check_bool_indexer(ax, key)
    417         mask = com.isnull(result)
    418         if mask.any():
--> 419             raise IndexingError('cannot index with vector containing '
    420                                 'NA / NaN values')                                                                                   
    421 

IndexingError: cannot index with vector containing NA / NaN values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant