|
88 | 88 | ABCSeries,
|
89 | 89 | )
|
90 | 90 | from pandas.core.dtypes.inference import is_list_like
|
91 |
| -from pandas.core.dtypes.missing import ( |
92 |
| - is_valid_nat_for_dtype, |
93 |
| - isna, |
94 |
| - na_value_for_dtype, |
95 |
| - notna, |
96 |
| -) |
| 91 | +from pandas.core.dtypes.missing import is_valid_nat_for_dtype, isna, notna |
97 | 92 |
|
98 | 93 | if TYPE_CHECKING:
|
99 | 94 | from pandas import Series
|
100 | 95 | from pandas.core.arrays import ExtensionArray
|
101 |
| - from pandas.core.indexes.base import Index |
102 | 96 |
|
103 | 97 | _int8_max = np.iinfo(np.int8).max
|
104 | 98 | _int16_max = np.iinfo(np.int16).max
|
@@ -488,53 +482,6 @@ def changeit():
|
488 | 482 | return result, False
|
489 | 483 |
|
490 | 484 |
|
491 |
| -def maybe_casted_values( |
492 |
| - index: "Index", codes: Optional[np.ndarray] = None |
493 |
| -) -> ArrayLike: |
494 |
| - """ |
495 |
| - Convert an index, given directly or as a pair (level, code), to a 1D array. |
496 |
| -
|
497 |
| - Parameters |
498 |
| - ---------- |
499 |
| - index : Index |
500 |
| - codes : np.ndarray[intp] or None, default None |
501 |
| -
|
502 |
| - Returns |
503 |
| - ------- |
504 |
| - ExtensionArray or ndarray |
505 |
| - If codes is `None`, the values of `index`. |
506 |
| - If codes is passed, an array obtained by taking from `index` the indices |
507 |
| - contained in `codes`. |
508 |
| - """ |
509 |
| - |
510 |
| - values = index._values |
511 |
| - if values.dtype == np.object_: |
512 |
| - values = lib.maybe_convert_objects(values) |
513 |
| - |
514 |
| - # if we have the codes, extract the values with a mask |
515 |
| - if codes is not None: |
516 |
| - mask: np.ndarray = codes == -1 |
517 |
| - |
518 |
| - if mask.size > 0 and mask.all(): |
519 |
| - # we can have situations where the whole mask is -1, |
520 |
| - # meaning there is nothing found in codes, so make all nan's |
521 |
| - |
522 |
| - dtype = index.dtype |
523 |
| - fill_value = na_value_for_dtype(dtype) |
524 |
| - values = construct_1d_arraylike_from_scalar(fill_value, len(mask), dtype) |
525 |
| - |
526 |
| - else: |
527 |
| - values = values.take(codes) |
528 |
| - |
529 |
| - if mask.any(): |
530 |
| - if isinstance(values, np.ndarray): |
531 |
| - values, _ = maybe_upcast_putmask(values, mask, np.nan) |
532 |
| - else: |
533 |
| - values[mask] = np.nan |
534 |
| - |
535 |
| - return values |
536 |
| - |
537 |
| - |
538 | 485 | def maybe_promote(dtype, fill_value=np.nan):
|
539 | 486 | """
|
540 | 487 | Find the minimal dtype that can hold both the given dtype and fill_value.
|
|
0 commit comments