You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df - df['a'] # does not give the desired result
a b 0 1 2
dim0
0 NaN NaN NaN NaN NaN
1 NaN NaN NaN NaN NaN
2 NaN NaN NaN NaN NaN
subtract, specifying which axis to match on (broadcasting happens on the other axis):
df.sub(df['a'], axis='index') # gives the desired result
dim1 a b
dim0
0 0.0 -0.434062
1 0.0 -0.502310
2 0.0 -0.189745
I am suggesting that the "-" operator would look at the names of the indices in the operands and match on the axis that has the same name in the two operands.
By way of motivation, I'm doing mass spectral matching of compounds, so I could name my indices 'chemical' and 'mass'.
The text was updated successfully, but these errors were encountered:
The concept resonates. It's exactly how xarray works - check that out if you want labelled dimensions fully supported.
For this to work in pandas, my POV is named indexes / dimensions need to be supported throughout operations. If we only implemented it for this case, it could feel a bit too magical.
In writing some math code in pandas, I find it necessary to do things like
instead of the shorter and more intuitive
in order to control the axis along which the series is broadcast.
I think it would be a big improvement syntactically if pandas would automatically broadcast down the axis that didn't have a matching name.
Example:
subtract:
subtract, specifying which axis to match on (broadcasting happens on the other axis):
I am suggesting that the "-" operator would look at the names of the indices in the operands and match on the axis that has the same name in the two operands.
By way of motivation, I'm doing mass spectral matching of compounds, so I could name my indices 'chemical' and 'mass'.
The text was updated successfully, but these errors were encountered: