|
50 | 50 | from pandas.core.dtypes.generic import (
|
51 | 51 | ABCCategorical,
|
52 | 52 | ABCDataFrame,
|
53 |
| - ABCDatetimeArray, |
54 | 53 | ABCDatetimeIndex,
|
55 | 54 | ABCIndexClass,
|
56 | 55 | ABCIntervalIndex,
|
@@ -460,11 +459,7 @@ def _simple_new(cls, values, name=None, dtype=None):
|
460 | 459 |
|
461 | 460 | Must be careful not to recurse.
|
462 | 461 | """
|
463 |
| - if isinstance(values, (ABCSeries, ABCIndexClass)): |
464 |
| - # Index._data must always be an ndarray. |
465 |
| - # This is no-copy for when _values is an ndarray, |
466 |
| - # which should be always at this point. |
467 |
| - values = np.asarray(values._values) |
| 462 | + assert isinstance(values, np.ndarray), type(values) |
468 | 463 |
|
469 | 464 | result = object.__new__(cls)
|
470 | 465 | result._data = values
|
@@ -510,17 +505,14 @@ def _get_attributes_dict(self):
|
510 | 505 | def _shallow_copy(self, values=None, **kwargs):
|
511 | 506 | if values is None:
|
512 | 507 | values = self.values
|
| 508 | + |
513 | 509 | attributes = self._get_attributes_dict()
|
514 | 510 | attributes.update(kwargs)
|
515 | 511 | if not len(values) and "dtype" not in kwargs:
|
516 | 512 | attributes["dtype"] = self.dtype
|
517 | 513 |
|
518 | 514 | # _simple_new expects an the type of self._data
|
519 | 515 | values = getattr(values, "_values", values)
|
520 |
| - if isinstance(values, ABCDatetimeArray): |
521 |
| - # `self.values` returns `self` for tz-aware, so we need to unwrap |
522 |
| - # more specifically |
523 |
| - values = values.asi8 |
524 | 516 |
|
525 | 517 | return self._simple_new(values, **attributes)
|
526 | 518 |
|
|
0 commit comments