-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Description
I think it is strange that .set_axis() can't accept index=/columns= kwargs, even though similar methods .rename(), .rename_axis(), .drop() and etc. can.
Personally, I think it would be more readable than specifying it with 0 or 1.
One trivial advantage is that it allows us to change rows and columns at once.
expect:
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
>>> df.set_axis(index=['a', 'b', 'c'])
A B
a 1 4
b 2 5
c 3 6
>>> df.set_axis(columns=['I', 'II'])
I II
0 1 4
1 2 5
2 3 6
>>> df.set_axis(index=['a', 'b', 'c'], columns=['I', 'II'])
I II
a 1 4
b 2 5
c 3 6levibaguley, leonarduschen and samukweku
Metadata
Metadata
Assignees
Labels
API - ConsistencyInternal Consistency of API/BehaviorInternal Consistency of API/BehaviorEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves