This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d594bc  ARROW-2273: [Python] Raise NotImplementedError when pandas 
Sparse types serializing
3d594bc is described below

commit 3d594bc971d6f7ae81b4e3c3940cd73da5acf0a7
Author: Licht-T <[email protected]>
AuthorDate: Sat May 5 10:47:20 2018 +0200

    ARROW-2273: [Python] Raise NotImplementedError when pandas Sparse types 
serializing
    
    This fixes [ARROW-2273](https://issues.apache.org/jira/browse/ARROW-2273).
    
    `pandas` Sparse types are planned to be deprecated in pandas future 
releases (https://github.com/pandas-dev/pandas/issues/19239).
    `SparseDataFrame` and `SparseSeries` are naive implementation and have many 
bugs. IMO, this is not the right time to support these in `pyarrow`.
    
    Author: Licht-T <[email protected]>
    
    Closes #1997 from Licht-T/add-pandas-sparse-unsupported-msg and squashes 
the following commits:
    
    64e24cee <Licht-T> ENH: Raise NotImplementedError when pandas Sparse types 
serializing pandas Sparse types are planned to be deprecated in pandas future 
releases. https://github.com/pandas-dev/pandas/issues/19239
---
 python/pyarrow/serialization.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/python/pyarrow/serialization.py b/python/pyarrow/serialization.py
index b3ef625..e2da760 100644
--- a/python/pyarrow/serialization.py
+++ b/python/pyarrow/serialization.py
@@ -81,13 +81,31 @@ def _register_custom_pandas_handlers(context):
 
     import pyarrow.pandas_compat as pdcompat
 
+    sparse_type_error_msg = (
+        '{0} serialization is not supported.\n'
+        'Note that {0} is planned to be deprecated '
+        'in pandas future releases.\n'
+        'See https://github.com/pandas-dev/pandas/issues/19239 '
+        'for more information.'
+    )
+
     def _serialize_pandas_dataframe(obj):
+        if isinstance(obj, pd.SparseDataFrame):
+            raise NotImplementedError(
+                sparse_type_error_msg.format('SparseDataFrame')
+            )
+
         return pdcompat.dataframe_to_serialized_dict(obj)
 
     def _deserialize_pandas_dataframe(data):
         return pdcompat.serialized_dict_to_dataframe(data)
 
     def _serialize_pandas_series(obj):
+        if isinstance(obj, pd.SparseSeries):
+            raise NotImplementedError(
+                sparse_type_error_msg.format('SparseSeries')
+            )
+
         return _serialize_pandas_dataframe(pd.DataFrame({obj.name: obj}))
 
     def _deserialize_pandas_series(data):

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to