The array that Series.values returns (public attribute). This has some historical constraints, and is overridden in block subclasses to return the correct array (e.g. period returns object ndarray and datetimetz a datetime64[ns] ndarray instead of proper extension array).
(values: ArrayLike)
| 2368 | |
| 2369 | |
| 2370 | def external_values(values: ArrayLike) -> ArrayLike: |
| 2371 | """ |
| 2372 | The array that Series.values returns (public attribute). |
| 2373 | |
| 2374 | This has some historical constraints, and is overridden in block |
| 2375 | subclasses to return the correct array (e.g. period returns |
| 2376 | object ndarray and datetimetz a datetime64[ns] ndarray instead of |
| 2377 | proper extension array). |
| 2378 | """ |
| 2379 | if isinstance(values, (PeriodArray, IntervalArray)): |
| 2380 | return values.astype(object) |
| 2381 | elif isinstance(values, (DatetimeArray, TimedeltaArray)): |
| 2382 | # NB: for datetime64tz this is different from np.asarray(values), since |
| 2383 | # that returns an object-dtype ndarray of Timestamps. |
| 2384 | # Avoid raising in .astype in casting from dt64tz to dt64 |
| 2385 | values = values._ndarray |
| 2386 | |
| 2387 | if isinstance(values, np.ndarray): |
| 2388 | values = values.view() |
| 2389 | values.flags.writeable = False |
| 2390 | else: |
| 2391 | # ExtensionArrays |
| 2392 | # TODO decide on read-only https://github.com/pandas-dev/pandas/issues/63099 |
| 2393 | # values = values.view() |
| 2394 | # values._readonly = True |
| 2395 | pass |
| 2396 | |
| 2397 | return values |
no test coverage detected