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
I have looked quickly at the python code implementing this and it appears that in both SparseArray.mean and SparseArray.sum the nsparse variable is counting the number of non-sparse entries rather than the number of sparse entries, and this is the cause of the incorrect values returned from these methods. I think that setting nsparse = self.sp_index.length - self.sp_index.npoints in both methods should fix this issue, but I don't understand the code well enough to be sure that this is correct.
@grsr that's pretty much what I did. Thanks for the input.
If you're looking for ways to get involved without digging too deep into the codebase, we'll soon start providing "Community" labels issues that we think are more discrete and require less staring at too much of pandas internals.
originally raised on pydata mailing list:
In [50]: DataFrame({'x': [1., 1.]}).to_sparse(fill_value=0).x.mean()
Out[50]: 0.5
In [51]: DataFrame({'x': [1., 1.]}).to_sparse().x.mean()
Out[51]: 1.0
The text was updated successfully, but these errors were encountered: