Skip to content

CLN: Change implementation of maybe_make_list #44071

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

Closed
rhshadrach opened this issue Oct 17, 2021 · 2 comments
Closed

CLN: Change implementation of maybe_make_list #44071

rhshadrach opened this issue Oct 17, 2021 · 2 comments
Labels
Clean Duplicate Report Duplicate issue or pull request Internals Related to non-user accessible pandas implementation Master Tracker High level tracker for similar issues

Comments

@rhshadrach
Copy link
Member

Ref: #41022 (comment)

Currently, the implementation is

def maybe_make_list(obj):
if obj is not None and not isinstance(obj, (tuple, list)):
return [obj]
return obj

This means that any list-like that is not a tuple nor list will be packed as a single element list, which is likely undesirable. For example, pd.crosstab works with ndarrays/Series but not lists/tuples for this reason (issue to come). I propose to change this method to:

def maybe_make_list_like(obj):
    if obj is None or is_list_like(obj):
        return obj
    else:
        return [obj]

I plan update this issue, listing out each part of the code that calls this function and what actions to take.

@rhshadrach rhshadrach added Internals Related to non-user accessible pandas implementation Master Tracker High level tracker for similar issues Clean labels Oct 17, 2021
@mroeschke
Copy link
Member

Does this overlap with #44056?

@rhshadrach
Copy link
Member Author

Ah, thanks @mroeschke, closing as a duplicate.

@rhshadrach rhshadrach added the Duplicate Report Duplicate issue or pull request label Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Duplicate Report Duplicate issue or pull request Internals Related to non-user accessible pandas implementation Master Tracker High level tracker for similar issues
Projects
None yet
Development

No branches or pull requests

2 participants