BUG: DataFrame.apply
labelling index and columns asymmetrically if axis=0/1.
#42005
Open
1 of 3 tasks
Uh oh!
There was an error while loading. Please reload this page.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Currently
DataFrame.apply
works asymmetrically.Along axis=0, the native index is maintained, if the shapes match and it is not overwritten by the function result object. When shapes don't match the created index is the default RangeIndex.
Along axis=1 (with result_type=expand), the native columns are overwritten by a default RangeIndex (even if it has same shape) unless overwritten by the function result object index.
Expected Output
Would anyone object to a PR that looks to unify the two cases and apply the columns index where the shapes were the same?
Currently I use the workaround:
Bug 1
Documentation states that for
result_type
arguments -These only act when axis=1 (columns):
.This is not true since:
The text was updated successfully, but these errors were encountered: