Skip to content

Commit 279329b

Browse files
author
y-p
committed
BUG: SparseSeries.density shouldn't die GH2803
1 parent f8cb40e commit 279329b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/sparse/series.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ def to_dense(self, sparse_only=False):
378378

379379
@property
380380
def density(self):
381-
return float(len(self.sp_index)) / len(self.index)
381+
r = float(self.sp_index.npoints) / float(self.sp_index.length)
382+
return r
382383

383384
def astype(self, dtype=None):
384385
"""

0 commit comments

Comments
 (0)