@@ -211,32 +211,37 @@ def _init_spmatrix(self, data, index, columns, dtype=None,
211
211
"""
212
212
Init self from scipy.sparse matrix.
213
213
"""
214
- index , columns = SparseFrameAccessor ._prep_index (data , index , columns )
215
- data = data .tocoo ()
216
- N = len (index )
217
-
218
- # Construct a dict of SparseSeries
219
- sdict = {}
220
- values = Series (data .data , index = data .row , copy = False )
221
- for col , rowvals in values .groupby (data .col ):
222
- # get_blocks expects int32 row indices in sorted order
223
- rowvals = rowvals .sort_index ()
224
- rows = rowvals .index .values .astype (np .int32 )
225
- blocs , blens = get_blocks (rows )
226
-
227
- sdict [columns [col ]] = SparseSeries (
228
- rowvals .values , index = index ,
229
- fill_value = fill_value ,
230
- sparse_index = BlockIndex (N , blocs , blens ))
231
-
232
- # Add any columns that were empty and thus not grouped on above
233
- sdict .update ({column : SparseSeries (index = index ,
234
- fill_value = fill_value ,
235
- sparse_index = BlockIndex (N , [], []))
236
- for column in columns
237
- if column not in sdict })
238
-
239
- return self ._init_dict (sdict , index , columns , dtype )
214
+ with warnings .catch_warnings ():
215
+ warnings .filterwarnings ('ignore' , 'SparseSeries' , FutureWarning )
216
+ index , columns = SparseFrameAccessor ._prep_index (data , index ,
217
+ columns )
218
+ data = data .tocoo ()
219
+ N = len (index )
220
+
221
+ # Construct a dict of SparseSeries
222
+ sdict = {}
223
+ values = Series (data .data , index = data .row , copy = False )
224
+ for col , rowvals in values .groupby (data .col ):
225
+ # get_blocks expects int32 row indices in sorted order
226
+ rowvals = rowvals .sort_index ()
227
+ rows = rowvals .index .values .astype (np .int32 )
228
+ blocs , blens = get_blocks (rows )
229
+
230
+ sdict [columns [col ]] = SparseSeries (
231
+ rowvals .values , index = index ,
232
+ fill_value = fill_value ,
233
+ sparse_index = BlockIndex (N , blocs , blens ))
234
+
235
+ # Add any columns that were empty and thus not grouped on above
236
+ sdict .update ({column : SparseSeries (index = index ,
237
+ fill_value = fill_value ,
238
+ sparse_index = BlockIndex (N ,
239
+ [],
240
+ []))
241
+ for column in columns
242
+ if column not in sdict })
243
+
244
+ return self ._init_dict (sdict , index , columns , dtype )
240
245
241
246
@Appender (SparseFrameAccessor .to_coo .__doc__ )
242
247
def to_coo (self ):
0 commit comments