Skip to content

Cannot increment after loc indexing #5771

Closed
@yarivm

Description

@yarivm
import pandas as pd
a = pd.Series(index=[4,5,6], data=0)
print a.loc[4:5]
a.loc[4:5] += 1

Yields:

4    0
5    0
Traceback (most recent call last):
  File "temp1.py", line 9, in <module>
dtype: int64
    a.loc[4:5] += 1
  File "lib\site-packages\pandas\core\indexing.py", line 88, in __setitem__
    self._setitem_with_indexer(indexer, value)
  File "lib\site-packages\pandas\core\indexing.py", line 177, in _setitem_with_indexer
    value = self._align_series(indexer, value)
  File "lib\site-packages\pandas\core\indexing.py", line 206, in _align_series
    raise ValueError('Incompatible indexer with Series')
ValueError: Incompatible indexer with Series

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