Closed parthm closed 6 years ago
Looking into the tests, there seems to be a specific test to ensure that the sum is nil
if the row contains any nils. So, I assume this is intended behavior at least for some use cases.
It may be worth going the pandas.DataFrame.sum route and having a skipnil
flag that defaults to false
. This would avoid breaking compatibility and also allow for the new behavior.
That said, if there aren't many folks out there counting on the old vector_sum
behavior, if may be good to make it more consistent with Vector#sum
and make skipnil: true
the default. It would be nice if Vector#sum
and vector_sum
behaved the same way by default. Eventually it may make sense to have a skipnil
flag in Vector#sum
as well.
Works. I like approach with flags.
Think this can be closed now the above PR has been merged?
Daru::DataFrame#vector_sum
makes the sumnil
if the row contains anil
. It may be worth while ignoring thenil
entries for sum.Note that the last row below shows the sum as
nil
instead of5
.Vector#sum
ignores nil and presents the sum correctly.DataFrame#vector_sum
ignoringnil
would make the behavior more consistent.Vector#sum
below ignores the 10th entry which isnil
.