You probably want
>>> df.sub(df.a, axis=0) abcde 0 0 0.112285 0.267105 0.365407 -0.159907 1 0 0.380421 0.119536 0.356203 0.096637 2 0 -0.100310 -0.180927 0.112677 0.260202 3 0 0.653642 0.566408 0.086720 0.256536
df-df.a basically tries to perform subtraction on the other axis, so the indices do not match, and when using binary operators such as subtraction, “inconsistent indices will be merged together” (as the docs say). Since the indices do not match, you end with 0 1 2 3 abcde .
For example, you could get an indirect indirect move, (df.T - df.a).T , which, turning df over, means that the default axis is now correct.
source share