Skip to content

ENH: IDEA Introduce axis→0/axis→1 arrow aliases to disambiguate direction vs. label operations #61336

@withlionbuddha

Description

@withlionbuddha

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

The `axis` parameter currently serves two distinct purposes:
  1. Along‑axis operations that reduce or transform values (e.g. apply, sum)
  2. Label‑targeting operations that modify or drop index / column labels (e.g. drop, rename)

Because both use the same syntax (axis=0 or axis=1), many users mis‑interpret which dimension is affected.

<한국어>
현재 axis 매개변수는 서로 다른 두 가지 목적으로 사용되고 있습니다:
값을 축소하거나 변환하는 축 방향 연산 (예: apply, sum)
인덱스/열 레이블을 수정하거나 삭제하는 레이블 대상 연산 (예: drop, rename)
두 경우 모두 동일한 구문(axis=0 또는 axis=1)을 사용하기 때문에 많은 사용자가 어떤 차원이 영향을 받는지 혼동합니다.

Feature Description

Proposed API Keep existing syntax and add an **arrow alias** that makes the “direction” explicit:
Syntax Meaning
axis=0 (unchanged) target index labels (delete / rename)
axis=1 (unchanged) target column labels
axis→0 (new) operate along index – treat each column vector
axis→1 (new) operate along columns – treat each row vector

Arrow aliases are optional; existing code keeps working unchanged.

<한국어>

제안된 API
기존 구문을 유지하면서 "방향"을 명확히 나타내는 화살표 별칭을 추가합니다

Syntax Meaning
axis=0 (변경없음) 인덱스 레이블 대상 (삭제 / 이름 변경)
axis=1 (변경없음) 열 레이블 대상
axis→0 (신규) 인덱스 방향으로 연산 – 각 열 벡터 처리
axis→1 (신규) 열 방향으로 연산 – 각 행 벡터 처리

화살표 별칭은 선택 사항이며, 기존 코드는 변경 없이 계속 작동합니다.

Alternative Solutions

Alias idea Interpretation
axis→0 operate along index (column‑wise)
axis→1 operate along columns (row‑wise)

Benefits

  • Greatly reduces beginner confusion around axis.
  • Preserves full NumPy compatibility.
  • Requires minimal code changes (add alias mapping in axis_aliases).

<한국어>

별칭 아이디어 해석
axis→0 인덱스 방향으로 연산 (열 단위)
axis→1 열 방향으로 연산 (행 단위)

장점
axis에 대한 초보자의 혼란을 크게 줄입니다.
NumPy 호환성을 완전히 유지합니다.
최소한의 코드 변경만 필요합니다 (axis_aliases에 별칭 매핑 추가).

Additional Context

See repeated questions on Stack Overflow:

https://stackoverflow.com/q/26716616.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions