-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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: Support dict to pd.set_option
for cleaner code
#61093
Comments
take |
working on this aah i missed it maybe if i have solution can i propose it @arthurlw |
Oh sorry @himanshumahajan138 I just saw your message. If you have a solution too we can discuss and compare! |
Hi @arthurlw and @himanshumahajan138. Thanks for making the PR. I think #61152 is cleaner, but has a higher risk of bug (if exist). Also, I don't think we need to support the |
@yasirroni actually i am struggling with the Tight code formatting fixtures 😅 Fixing the failing doc tests and type tests after that we can have discussions on approach suitability |
cc @pandas-dev/pandas-core for any thoughts. |
I think it's a good idea to support a |
I think it's a good addition, the same time makes things a bit complicated. @Dr-Irv makes the API clearer in my opinion, but I would prefer to not have to add and maintain one more method being almoat identical to the existing. An idea could be since we are addimg a way to pass multiple options, to allow only one option and remove In any case, I'm ok with any option. |
Good wishes Members, Actually my PR consists both approaches first one is only for PR : #61152 |
For my PR (#61151), I implemented the first approach only, which is I think this would be simpler, but I am okay with either option. |
I think the issue with this is that |
Just to be sure, I think you mean to deprecate |
If we support dictionaries, I think it would make sense to deprecate |
This is not really a benefit for existing users that already the functionality of the current API to set multiple options at once? |
Reposting my response from the PR: I find this to be a rough edge in pandas. Is there another package that allows the specification of options/configurations/settings as an iterable of alternating key-value pairs? It seems to me like an odd choice for an API, and one that we can improve by having users supply a data structure that more naturally embodies the key-value relationship. |
I agree! I'm all for having good design principles. |
I would be +1 on supporting a mapping input. I would be -0 on deprecating the current |
-1 is for the deprecation. I think also that, without the deprecation, the enhancement could be conceptionally as simple as... if len(args) == 1 and isinstance(args[0], dict):
args = [elem for pair in args[0].items() for elem in pair] which does not appear to be the maintenance burden to justify the deprecation. The current PR has 2 extra branches and a lot of duplicated logic which is more of a maintenance burden IMHO. |
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
I wish that I could use dict for
pd.set_option
, just like other packages typically accept dict when there are lots of option. Current pandas style follow what old programming language do, such as MATLAB.Feature Description
Alternative Solutions
Current implementations is:
Additional Context
Because if I write it like this:
An auto formatter like
ruff
will make it into:The text was updated successfully, but these errors were encountered: