(self, other, sort)
| 4251 | # Set Methods |
| 4252 | |
| 4253 | def _union(self, other, sort) -> MultiIndex: |
| 4254 | other, result_names = self._convert_can_do_setop(other) |
| 4255 | if other.has_duplicates: |
| 4256 | # This is only necessary if other has dupes, |
| 4257 | # otherwise difference is faster |
| 4258 | result = super(MultiIndex, self.rename(result_names))._union( |
| 4259 | other.rename(result_names), sort |
| 4260 | ) |
| 4261 | |
| 4262 | if isinstance(result, MultiIndex): |
| 4263 | return result |
| 4264 | return MultiIndex.from_arrays( |
| 4265 | zip(*result, strict=True), sortorder=None, names=result_names |
| 4266 | ) |
| 4267 | |
| 4268 | else: |
| 4269 | right_missing = other.difference(self, sort=False) |
| 4270 | if len(right_missing): |
| 4271 | result = self.append(right_missing) |
| 4272 | else: |
| 4273 | result = self._get_reconciled_name_object(other) |
| 4274 | |
| 4275 | if sort is not False: |
| 4276 | try: |
| 4277 | result = result.sort_values() |
| 4278 | except TypeError: |
| 4279 | if sort is True: |
| 4280 | raise |
| 4281 | warnings.warn( |
| 4282 | "The values in the array are unorderable. " |
| 4283 | "Pass `sort=False` to suppress this warning.", |
| 4284 | RuntimeWarning, |
| 4285 | stacklevel=find_stack_level(), |
| 4286 | ) |
| 4287 | return result |
| 4288 | |
| 4289 | def _is_comparable_dtype(self, dtype: DtypeObj) -> bool: |
| 4290 | return is_object_dtype(dtype) |
nothing calls this directly
no test coverage detected