-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
ENH: Categorical.from_union #13410
Comments
I think the location is fine. This mostly is part of a developer/extender API, e.g. used internally by other parts of pandas and other packages (e.g. dask), rather than in an of itself useful to a regular user. |
+1 for adding a |
xref #13410, #13524 Author: sinhrks <[email protected]> Closes #13763 from sinhrks/union_categoricals_ordered and squashes the following commits: 9cadc4e [sinhrks] ENH: union_categorical supports identical categories with ordered
It was #14199, but yes - I edited the top comment. |
@jreback @JanSchulz
|
Setup In [15]: c1 = pd.Categorical(['a', 'a', 'b'], categories=['b', 'a', 'c'], ordered=True)
In [16]: c2 = pd.Categorical(['b', 'b', 'a'])
In [17]: union_categoricals([c1, c2])
TypeError: Categorical.ordered must be the same For your first question - the idea would be to allow this In [18]: union_categoricals([c1, c2], ignore_order=True)
[a, a, b, b, b, a]
Categories (3, object): [b, a, c] On your second question - not sure if there's complete agreement on the API, but assuming there is a |
the |
Thank you all for the comments. I have made an attempt at a pull request to support the ignore_order argument. #15219 I will hold off on from_union until there is agreement on the API change. |
xref #13410 (ignore_order portion) Author: Justin Solinsky <[email protected]> Closes #15219 from js3711/GH13410-ENHunion_categoricals and squashes the following commits: e9d00de [Justin Solinsky] GH15219 Documentation fixes based on feedback d278d62 [Justin Solinsky] ENH union_categoricals supports ignore_order GH13410 9b827ef [Justin Solinsky] ENH union_categoricals supports ignore_order GH13410
so to close this issue, I think we need to add |
xref pandas-dev#13410 (ignore_order portion) Author: Justin Solinsky <[email protected]> Closes pandas-dev#15219 from js3711/GH13410-ENHunion_categoricals and squashes the following commits: e9d00de [Justin Solinsky] GH15219 Documentation fixes based on feedback d278d62 [Justin Solinsky] ENH union_categoricals supports ignore_order GH13410 9b827ef [Justin Solinsky] ENH union_categoricals supports ignore_order GH13410
I haven't seen a huge demand for this in the 6 years since the last comment, so lean against adding this to the API. |
Agreed, closing but we can reopen if there interest again |
xref #13361
Series/CategoricalIndex
as well asCategorical
BUG: union_categorical with Series and cat idx #14199ignore_order
to ignore the raising on an ordered Categorical (and just have it work) ENH union_categoricals supports ignore_order GH13410 #15219pd
namespace (or change its name). ConsiderCategorical.from_union(...)
The text was updated successfully, but these errors were encountered: