Skip to content

Assignment using .ix[] raises ValueError #5928

Closed
@twiecki

Description

@twiecki

This works with 0.12 but not with master:

In [8]: import pandas as pd
In [10]: x = pd.DataFrame({'a': [1, 2, 3]})
In [13]: x['a'].ix[[0, 1, 2]] = -x['a'].ix[[0, 1, 2]]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-30fcfd21bb22> in <module>()
----> 1 x['a'].ix[[0, 1, 2]] = -x['a'].ix[[0, 1, 2]]

/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
     94             indexer = self._convert_to_indexer(key, is_setter=True)
     95 
---> 96         self._setitem_with_indexer(indexer, value)
     97 
     98     def _has_valid_type(self, k, axis):

/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value)
    409 
    410             if isinstance(value, ABCSeries):
--> 411                 value = self._align_series(indexer, value)
    412 
    413             elif isinstance(value, ABCDataFrame):

/home/wiecki/envs/hddm/local/lib/python2.7/site-packages/pandas/core/indexing.py in _align_series(self, indexer, ser)
    516             return ser.reindex(ax).values
    517 
--> 518         raise ValueError('Incompatible indexer with Series')
    519 
    520     def _align_frame(self, indexer, df):

ValueError: Incompatible indexer with Series
> /home/wiecki/envs/hddm/local/lib/python2.7/site-packages/pandas/core/indexing.py(518)_align_series()
    517 
--> 518         raise ValueError('Incompatible indexer with Series')
    519 

This is where it showed up: hddm-devs/hddm#35

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions