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
Pandas now supports creating sparse dataframes directly from ``scipy.sparse.spmatrix`` instances.
246
+
See the :ref:`documentation <sparse.scipysparse>` for more information. (:issue:`4343`)
247
+
248
+
All sparse formats are supported, but matrices that are not in :mod:`COOrdinate <scipy.sparse>` format will be converted, copying data as needed.
249
+
250
+
.. ipython:: python
251
+
252
+
from scipy.sparse import csr_matrix
253
+
arr = np.random.random(size=(1000, 5))
254
+
arr[arr < .9] = 0
255
+
sp_arr = csr_matrix(arr)
256
+
sp_arr
257
+
sdf = pd.SparseDataFrame(sp_arr)
258
+
sdf
259
+
260
+
To convert a ``SparseDataFrame`` back to sparse SciPy matrix in COO format, you can use:
261
+
262
+
.. ipython:: python
263
+
264
+
sdf.to_coo()
265
+
240
266
.. _whatsnew_0200.enhancements.other:
241
267
242
268
Other enhancements
243
269
^^^^^^^^^^^^^^^^^^
270
+
244
271
- Integration with the ``feather-format``, including a new top-level ``pd.read_feather()`` and ``DataFrame.to_feather()`` method, see :ref:`here <io.feather>`.
245
272
- ``Series.str.replace()`` now accepts a callable, as replacement, which is passed to ``re.sub`` (:issue:`15055`)
246
273
- ``Series.str.replace()`` now accepts a compiled regular expression as a pattern (:issue:`15446`)
@@ -752,7 +779,6 @@ Bug Fixes
752
779
- Bug in ``Rolling.quantile`` function that caused a segmentation fault when called with a quantile value outside of the range [0, 1] (:issue:`15463`)
753
780
- Bug in ``pd.cut()`` with a single bin on an all 0s array (:issue:`15428`)
754
781
- Bug in ``pd.qcut()`` with a single quantile and an array with identical values (:issue:`15431`)
755
-
- Bug in ``SparseSeries.reindex`` on single level with list of length 1 (:issue:`15447`)
756
782
757
783
758
784
@@ -783,6 +809,7 @@ Bug Fixes
783
809
- Bug in ``to_sql`` when writing a DataFrame with numeric index names (:issue:`15404`).
784
810
- Bug in ``Series.iloc`` where a ``Categorical`` object for list-like indexes input was returned, where a ``Series`` was expected. (:issue:`14580`)
785
811
- Bug in repr-formatting a ``SparseDataFrame`` after a value was set on (a copy of) one of its series (:issue:`15488`)
812
+
- Bug in ``SparseSeries.reindex`` on single level with list of length 1 (:issue:`15447`)
786
813
787
814
788
815
- Bug in groupby operations with timedelta64 when passing ``numeric_only=False`` (:issue:`5724`)
0 commit comments