You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, it should return an ExtensionArray when passed an ExtensionDtype.
This ends up making .astype quite complicated in practice. Pandas should provide some helpers here (though we had an issue for that, but couldn't quickly find one).
In the meantime, the EA docs / code should recommend a few things
Use pandas_dtype(dtype) to convert strings like Period[D] to the ExtensionDtype or numba dtype
For extension types, recommending dtype.construct_array_type()._from_sequencemay make sense, but I'm not sure. That's supposed to take sequences of the scalar, so in theory it'll only work when you have to different ExtensionDtypes for the same scalar type. Not sure how common that'll be.
pandas/pandas/core/arrays/base.py
Line 324 in 6d3565a
Should the docstring say that this should return an ExtensionArray when an ExtensionType is passed into it?
I note that PeriodArray behaves like this.
pandas.core.dtypes.dtypes.PeriodDtype
pandas.core.arrays.period.PeriodArray
The text was updated successfully, but these errors were encountered: