Skip to content

Commit bcf41b5

Browse files
BUG: Fixed GH 16179 in a more elegant manner
1 parent 5b0f14e commit bcf41b5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pandas/core/sparse/frame.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,12 @@ def _init_spmatrix(self, data, index, columns, dtype=None,
190190
values = Series(data.data, index=data.row, copy=False)
191191
for col, rowvals in values.groupby(data.col):
192192
# get_blocks expects int32 row indices in sorted order
193+
rowvals.sort_index(inplace=True)
193194
rows = rowvals.index.values.astype(np.int32)
194-
vals = np.array([y for x, y in sorted(rowvals.iteritems())],
195-
dtype=rowvals.dtype)
196-
rows.sort()
197195
blocs, blens = get_blocks(rows)
198196

199197
sdict[columns[col]] = SparseSeries(
200-
vals, index=index,
198+
rowvals.values, index=index,
201199
fill_value=fill_value,
202200
sparse_index=BlockIndex(N, blocs, blens))
203201

0 commit comments

Comments
 (0)