REF: Implement NDArrayBackedExtensionArray by jbrockmendel · Pull Request #33660 · pandas-dev/pandas (original) (raw)

Many EAs are thin wrappers around np.ndarray. We can both de-duplicate a bunch of code and make things easier on downstream authors by implementing NDArrayBackedExtensionArray as a base class for such EAs.

This PR only implements NDArrayBackedExtensionArray.take, but there is quite a bit more that can be shared in follow-ups:

The only change in logic this PR makes is to make Categorical.take raise a ValueError instead of a TypeError, matching DTA/TDA/PA.