wesm / pandas2

Design documents and code for the pandas 2.0 effort.
https://pandas-dev.github.io/pandas2/
306 stars 41 forks source link

Aligning Series.index with DataFrame.index in broadcasting operations #30

Open shoyer opened 7 years ago

shoyer commented 7 years ago

Copying my comment from https://github.com/pydata/pandas/issues/10000#issuecomment-236238297:

We should consider making arithmetic between a Series and a DataFrame broadcast across the columns of the dataframe, i.e., aligning series.index with df.index, rather than the current behavior aligning series.index with df.columns.

I think this would be far more useful than the current behavior, because it's much more common to want to do arithmetic between a series and all columns of a DataFrame. This would make broadcasting in pandas inconsistent with NumPy, but I think that's OK for a library that focuses on 1D/2D rather than N-dimensional data structures.

wesm commented 7 years ago

I honestly might even go so far as disabling implicit broadcasting in favor of df.add(series, axis='index'). Perennial source of problems.