Skip to content

CLN: Change implementation of maybe_make_list #44071

Closed
@rhshadrach

Description

@rhshadrach

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CleanDuplicate ReportDuplicate issue or pull requestInternalsRelated to non-user accessible pandas implementationMaster TrackerHigh level tracker for similar issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions