|
2 | 2 | Base and utility classes for tseries type pandas objects.
|
3 | 3 | """
|
4 | 4 | from datetime import datetime
|
5 |
| -from typing import Any, List, Optional, Union |
| 5 | +from typing import Any, List, Optional, Union, cast |
6 | 6 |
|
7 | 7 | import numpy as np
|
8 | 8 |
|
@@ -583,6 +583,22 @@ def delete(self, loc):
|
583 | 583 | arr = type(self._data)._simple_new(new_i8s, dtype=self.dtype, freq=freq)
|
584 | 584 | return type(self)._simple_new(arr, name=self.name)
|
585 | 585 |
|
| 586 | + # -------------------------------------------------------------------- |
| 587 | + # Join/Set Methods |
| 588 | + |
| 589 | + def _wrap_joined_index(self, joined: np.ndarray, other): |
| 590 | + assert other.dtype == self.dtype, (other.dtype, self.dtype) |
| 591 | + name = get_op_result_name(self, other) |
| 592 | + |
| 593 | + if is_period_dtype(self.dtype): |
| 594 | + freq = self.freq |
| 595 | + else: |
| 596 | + self = cast(DatetimeTimedeltaMixin, self) |
| 597 | + freq = self.freq if self._can_fast_union(other) else None |
| 598 | + new_data = type(self._data)._simple_new(joined, dtype=self.dtype, freq=freq) |
| 599 | + |
| 600 | + return type(self)._simple_new(new_data, name=name) |
| 601 | + |
586 | 602 |
|
587 | 603 | class DatetimeTimedeltaMixin(DatetimeIndexOpsMixin, Int64Index):
|
588 | 604 | """
|
@@ -878,15 +894,6 @@ def _is_convertible_to_index_for_join(cls, other: Index) -> bool:
|
878 | 894 | return True
|
879 | 895 | return False
|
880 | 896 |
|
881 |
| - def _wrap_joined_index(self, joined: np.ndarray, other): |
882 |
| - assert other.dtype == self.dtype, (other.dtype, self.dtype) |
883 |
| - name = get_op_result_name(self, other) |
884 |
| - |
885 |
| - freq = self.freq if self._can_fast_union(other) else None |
886 |
| - new_data = type(self._data)._simple_new(joined, dtype=self.dtype, freq=freq) |
887 |
| - |
888 |
| - return type(self)._simple_new(new_data, name=name) |
889 |
| - |
890 | 897 | # --------------------------------------------------------------------
|
891 | 898 | # List-Like Methods
|
892 | 899 |
|
|
0 commit comments