-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
px.Constant and the "identity" problem #2119
Comments
@emmanuelle thoughts? |
@nicolaskruchten |
Ah yeah, a simple string would work too and we could build the identity map internally :) I think also that since constant will be a class it should be capitalized also, right? |
Ah yes, it needs to be a class because of the label... so |
Updated the description above to use a capital. |
px.Constant
In certain cases to get the kind of output one would want with PX we need to create a dummy column containing the same string or number in each row. I propose to create a special kind of object that we could pass into the
px
functions to do this like:which would be a shortcut for:
px.Identity
+px.Direct
(identity option 1)Relatedly, but on a different note, one might have a column that directly encodes something like the color, and we might want a similar mechanism for doing something like
which would be a shortcut for:
Using the two together would allow you to force a single series to a single color:
and this might warrant its own shortcut, maybe
px.Direct
?which would be a more-intuitive shortcut for the following equivalent calls, in terms of their output:
px.IDENTITY_MAP
(identity option 2)A slightly different way of solving the "identity" problem would be to be able to pass in a magic value to
*_map
(edit: which per @emmanuelle could be just the string"identity"
!) like this:which would also be the equivalent of
This would avoid the need for nesting
px.Constant
andpx.Identity
when you want to use constant and identity together, and would mean no need forpx.Direct
as shortcut for that:(note that the foregoing could also apply to any groupable attrs beyond
color
likesymbol
orline_dash
)The text was updated successfully, but these errors were encountered: