API: .str ops on category should return category if result is non-boolean #15198
Labels
Categorical
Categorical Data Type
Enhancement
Needs Discussion
Requires discussion from core team before further action
Strings
String extension data type and string data
Uh oh!
There was an error while loading. Please reload this page.
In the PR implementing
.str/.dt
on Categoricals, #11582.This is perfectly reasonable. We perform the string op on the uniques. This routine is a boolean result, so we return a boolean result.
However, I don't recall the rationale for: performing the op on the uniques (as its a categorical), but then returning an
object
dtype.These are by-definition pure transforms, and so a new categorical makes sense. e.g. in this case
This will be way more efficient than actually converting to object.
The text was updated successfully, but these errors were encountered: