Skip to content

Alignment of CategoricalIndex #13365

@toobaz

Description

@toobaz

Code Sample, a copy-pastable example if possible

In [2]: c = pd.CategoricalIndex(['3z53', '3z53', 'LoJG', 'LoJG', 'LoJG', 'N503'])

In [3]: s1 = pd.Series(2, index=c)

In [4]: s2 = pd.Series(2, index=c[:-1])

In [5]: s1*s2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-7426096cfe41> in <module>()
----> 1 s1*s2

/home/pietro/nobackup/repo/pandas/pandas/core/ops.py in wrapper(left, right, name, na_op)
    647             else:
    648                 index, lidx, ridx = left.index.join(rindex, how='outer',
--> 649                                                     return_indexers=True)
    650 
    651                 if lidx is not None:

/home/pietro/nobackup/repo/pandas/pandas/indexes/base.py in join(self, other, how, level, return_indexers)
   2524         if not self.is_unique and not other.is_unique:
   2525             return self._join_non_unique(other, how=how,
-> 2526                                          return_indexers=return_indexers)
   2527         elif not self.is_unique or not other.is_unique:
   2528             if self.is_monotonic and other.is_monotonic:

/home/pietro/nobackup/repo/pandas/pandas/indexes/base.py in _join_non_unique(self, other, how, return_indexers)
   2616         join_index = self.values.take(left_idx)
   2617         mask = left_idx == -1
-> 2618         np.putmask(join_index, mask, other._values.take(right_idx))
   2619 
   2620         join_index = self._wrap_joined_index(join_index, other)

TypeError: putmask() argument 1 must be numpy.ndarray, not Categorical

Expected Output

No error

output of pd.show_versions()

In [6]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.5.0-2-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: it_IT.utf8

pandas: 0.18.1+102.g0c6226c
nose: 1.3.7
pip: 1.5.6
setuptools: 18.4
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.16.0
statsmodels: 0.8.0.dev0+0fac349
xarray: None
IPython: 5.0.0.dev
sphinx: 1.3.1
patsy: 0.3.0-dev
dateutil: 2.2
pytz: 2012c
blosc: None
bottleneck: 1.1.0dev
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: 0.7.3
lxml: None
bs4: 4.4.0
html5lib: 0.999
httplib2: 0.9.1
apiclient: 1.5.0
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
pandas_datareader: 0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions