-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API: Add str/dt accessors to categorical #10661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
xref to #8627 What you are saying is the should ALSO allow the dtype correct accessor for its values (or categories if its a Categorical), in addition to the |
So, what this should do is simple allow the |
One solution (for
|
@JanSchulz not at all. This needs to operate on the categories, then return a new categorical object that has (transformed values).
|
ok, on it... |
Ok, what should that return:
-> a series of type string/object or a series of type category where the categories are of dtype str (and transformed)? I would go for the first, as it would honor the contract for str, which says it's a string: from http://pandas.pydata.org/pandas-docs/stable/api.html#string-handling
|
@JanSchulz , no I would change the docs. The point of using a |
This is slightly more tricky though (and its actually an example where it is quite useful). Note that [123] as I show below is actually pretty inefficient, as I already know the indexers. I think we can compute that directly.
|
I really hate that argument: "The point of using a category dtype is that it essentially acts like its object cousin, but is simply more efficient". Can't we get a |
Ok, found a case where it should not result in a category:
|
Another problem if we would return a category: should it be ordered or not? |
Ok, I have PR which returns normal Series (not categories) so that you can concat substrings ( |
I don't think we should try to return categorical here. There are way too many cornercases in all of the string manipulation functions to deal with which are all a bit subjective. Eg what to do with |
I think the concatenation of strings with |
@jorisvandenbossche |
ah, sorry, I misread your comment above that you wanted to do |
@jorisvandenbossche jep, exactly: if |
closed by #11582 |
Accessors should be enabled depending on
categories
. Should careCategoricalIndex
also.The text was updated successfully, but these errors were encountered: