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
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.19.0.txt
+18-1
Original file line number
Diff line number
Diff line change
@@ -323,7 +323,24 @@ These changes allow pandas to handle sparse data with more dtypes, and for work
323
323
324
324
s + 1
325
325
326
+
- Sparse data structure now support ``astype`` to convert internal ``dtype`` (:issue:`13900`)
326
327
328
+
.. ipython:: python
329
+
330
+
s = pd.SparseSeries([1., 0., 2., 0.], fill_value=0)
331
+
s
332
+
s.astype(np.int64)
333
+
334
+
``astype`` fails if data contains values which cannot be converted to specified ``dtype``.
335
+
Note that the limitation is applied to ``fill_value`` which default is ``np.nan``.
336
+
337
+
.. code-block:: ipython
338
+
339
+
In [7]: pd.SparseSeries([1., np.nan, 2., np.nan], fill_value=np.nan).astype(np.int64)
340
+
Out[7]:
341
+
ValueError: unable to coerce current fill_value nan to int64 dtype
342
+
343
+
- Subclassed ``SparseDataFrame`` and ``SparseSeries`` now preserve class types when slicing or transposing. (:issue:`13787`)
327
344
- Bug in ``SparseSeries`` with ``MultiIndex`` ``[]`` indexing may raise ``IndexError`` (:issue:`13144`)
328
345
- Bug in ``SparseSeries`` with ``MultiIndex`` ``[]`` indexing result may have normal ``Index`` (:issue:`13144`)
329
346
- Bug in ``SparseDataFrame`` in which ``axis=None`` did not default to ``axis=0`` (:issue:`13048`)
@@ -411,7 +428,7 @@ API changes
411
428
- ``pd.Timedelta(None)`` is now accepted and will return ``NaT``, mirroring ``pd.Timestamp`` (:issue:`13687`)
412
429
- ``Timestamp``, ``Period``, ``DatetimeIndex``, ``PeriodIndex`` and ``.dt`` accessor have gained a ``.is_leap_year`` property to check whether the date belongs to a leap year. (:issue:`13727`)
413
430
- ``pd.read_hdf`` will now raise a ``ValueError`` instead of ``KeyError``, if a mode other than ``r``, ``r+`` and ``a`` is supplied. (:issue:`13623`)
414
-
- Subclassed ``SparseDataFrame`` and ``SparseSeries`` now preserve class types when slicing or transposing. (:issue:`13787`)
0 commit comments