'ValueError: Cannot assign nan to integer series" when calling where on Series with non-unique index. (original) (raw)

Create a Series with non-unique index:

import pandas as pd pd.version '0.12.0' s1 = pd.Series(range(3)) s2 = pd.Series(range(3)) comb = pd.concat([s1,s2]) comb 0 0 1 1 2 2 0 0 1 1 2 2 dtype: int64

As of #4548 I cannot use comb[comb<2] =+ 10, so I tried working with where (according to http://pandas.pydata.org/pandas-docs/stable/indexing.html#where-and-masking, stating "To guarantee that selection output has the same shape as the original data, you can use the where method in Series and DataFrame"). But already calling where on comb is problematic:

comb.where(comb < 2) Traceback (most recent call last): File "", line 1, in File "/projects/bioinfp_apps/Python-2.7.3/lib/python2.7/site-packages/pandas/core/series.py", line 745, in where ser._set_with(~cond, other) File "/projects/bioinfp_apps/Python-2.7.3/lib/python2.7/site-packages/pandas/core/series.py", line 886, in _set_with self._set_values(key, value) File "/projects/bioinfp_apps/Python-2.7.3/lib/python2.7/site-packages/pandas/core/series.py", line 904, in _set_values values[key] = _index.convert_scalar(values, value) File "index.pyx", line 547, in pandas.index.convert_scalar (pandas/index.c:9752) File "index.pyx", line 560, in pandas.index.convert_scalar (pandas/index.c:9639) ValueError: Cannot assign nan to integer series

Is this expected?