Skip to content

REF: use _get_axis_number instead of if axis in [...]: #43048

Closed
@attack68

Description

@attack68

This PR regards searching the non-test codebase (i.e. don't find code examples in pandas/tests) for examples like the following:

Try to find and replace logic like:

if axis in [0, "index"]:
    ...
elif axis in [1, "columns"]:
    ...
else:
    ...

with the standard codebase method get_axis_number(axis). This is a DataFrame method so often you need use local DataFrame objects to call this method.

It may also be necessary to change axis args in internal methods to consistently accept the same input format compatible with this method, i.e. axis as an integer (0 or 1).

This is an open issue and contributions are welcome to solve individual files in the code. As an example see #43078 or other merged contributions below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RefactorInternal refactoring of code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions