Open mikedewar opened 12 years ago
Panda's combine does the trick nicely:
combiner = lambda x, y: np.where(isnull(x), y, x)
df1.combine(df2, combiner)
That's great! One thing though: do we want all this functionality by massively overloading the addition operator?
One consequence of this would be many isinstance
checks in __add__
which I find incredibly ugly! Maybe we can have reasonable helper functions that do this data combination for you. The main thing I don't like about overloading add this way is that you never know what the result of the operation is: it does drastically different things based on the incoming type. (this is one of the things I hate most about my implementation of the javascript module).
So, any thoughts?
The new method should look like
and the internal data frame should have merged the xs and added missing data for the ys and zs that don't have data points.