def _add_categorical_dummies(self, panel, cat_mappings):
        """
        Add categorical dummies to panel

        Returns
        -------
        DataFrame
        """
        if not self._x_effects:
            return panel

        dropped_dummy = (self._entity_effects and not self._use_all_dummies)

        for effect in self._x_effects:
            self.log('-- Adding fixed effect dummies for %s' % effect)

            dummies = get_dummies(panel[effect])

            val_map = cat_mappings.get(effect)
            if val_map:
                val_map = dict((v, k) for k, v in compat.iteritems(val_map))

            if dropped_dummy or not self._use_all_dummies:
                if effect in self._dropped_dummies:
                    to_exclude = mapped_name = self._dropped_dummies.get(
                        effect)

                    if val_map:
                        mapped_name = val_map[to_exclude]
                else:
                    to_exclude = mapped_name = dummies.columns[0]

                if mapped_name not in dummies.columns:  # pragma: no cover
                    raise Exception('%s not in %s' % (to_exclude,
                                                      dummies.columns))

                self.log(
                    '-- Excluding dummy for %s: %s' % (effect, to_exclude))

                dummies = dummies.filter(
                    dummies.columns.difference([mapped_name]))
                dropped_dummy = True

            dummies = _convertDummies(dummies, cat_mappings.get(effect))
            dummies = dummies.add_prefix(effect % '%s_')
            panel = panel.join(dummies)

        return panel
dataset/ETHPy150Open pydata/pandas/pandas/stats/plm.py/PanelOLS._add_categorical_dummies/swapped operands of `%`