Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible indexer with Series

Tags:

pandas

Why do I get an error:

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

Output:

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

Pandas 0.12.

like image 573
Yariv Avatar asked Dec 25 '13 11:12

Yariv


1 Answers

I think this is a bug, you can work around this by use tuple index:

import pandas as pd
a = pd.Series(index=[4,5,6], data=0)
print a.loc[4:5]
a.loc[4:5,] += 1
like image 111
HYRY Avatar answered Nov 15 '22 21:11

HYRY