Skip to content

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

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
1 of 3 tasks
withlionbuddha opened this issue Apr 22, 2025 · 4 comments
Labels
Closing Candidate May be closeable, needs more eyeballs Enhancement Needs Discussion Requires discussion from core team before further action

Comments

@withlionbuddha
Copy link

withlionbuddha commented Apr 22, 2025

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.

@withlionbuddha withlionbuddha added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 22, 2025
@withlionbuddha
Copy link
Author

Speaking as a research developer who relies on pandas daily:

Most “axis confusion” cases we see in internal code reviews stem from the dual meaning of axis=0 / 1.
A symbolic alias such as axis→0 / axis→1 instantly separates direction from label, benefitting not only experienced users but also students who are just learning pandas for the first time.
The change is fully backward‑compatible, so it poses no risk to existing codebases.

+1 to this proposal — happy to help with docs or a small PR if the core team agrees.

<한국어>
pandas를 일상적으로 사용하는 연구개발자로서 의견 남깁니다.

사내 코드 리뷰에서 발생하는 axis=0 / 1 혼란의 대부분은 방향 vs. 라벨의 이중 의미 때문입니다.
axis→0 / axis→1 같은 기호 alias가 있으면 두 개념을 명확히 구분할 수 있어, 숙련자뿐 아니라 pandas를 처음 배우는 학생들에게도 이해 부담을 크게 줄여 줍니다.
기존 문법과 완전히 호환되므로 기존 코드베이스에 영향을 주지 않습니다.

제안에 전적으로 찬성합니다. 코어팀이 승인한다면 문서 보완이나 간단한 PR 작업에 기여하겠습니다.

@withlionbuddha withlionbuddha changed the title ENH: IDEA ENH: IDEA Introduce axis→0/axis→1 arrow aliases to disambiguate direction vs. label operations Apr 22, 2025
@Liam3851
Copy link
Contributor

Liam3851 commented Apr 22, 2025

Thanks, it's an interesting thought but this does not seem implementable as it would not be valid python.

In [21]: def f(axis->1):
    ...:     pass
 Cell In[21], line 1
    def f(axis->1):
              ^
SyntaxError: invalid syntax

@rhshadrach
Copy link
Member

I am also negative on any non-ASCII functions / arguments in pandas.

@rhshadrach rhshadrach added Needs Discussion Requires discussion from core team before further action Closing Candidate May be closeable, needs more eyeballs and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 22, 2025
@mroeschke
Copy link
Member

Agreed with the response so far. Additionally I am not fond of having multiple ways to specify things.

Since there's not a lot of positive reception for this feature. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Enhancement Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

4 participants