You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2018/05/29 12:49:48 UTC

[arrow] branch master updated: ARROW-2593: [Python] TypeError: data type "mixed-integer" not understood

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 1a922fd  ARROW-2593: [Python] TypeError: data type "mixed-integer" not understood
1a922fd is described below

commit 1a922fdec8793544ac3679eaa157fc762f069f37
Author: Krisztián Szűcs <sz...@gmail.com>
AuthorDate: Tue May 29 14:49:13 2018 +0200

    ARROW-2593: [Python] TypeError: data type "mixed-integer" not understood
    
    Both `name` and `field_name` is [enforced](https://github.com/apache/arrow/blob/master/python/pyarrow/pandas_compat.py#L167) to be a string, but that way we lose the type of it (an integer in this case).
    Could We use one of it to preserve the original type of the column name?
    
    Author: Krisztián Szűcs <sz...@gmail.com>
    
    Closes #2084 from kszucs/ARROW-2593 and squashes the following commits:
    
    0e6d5330 <Krisztián Szűcs> maintain column order
    9e0ad334 <Krisztián Szűcs> reconstruct columns from pandas mixed-integer type
---
 python/pyarrow/pandas_compat.py             | 1 +
 python/pyarrow/tests/test_convert_pandas.py | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/python/pyarrow/pandas_compat.py b/python/pyarrow/pandas_compat.py
index 18d8ed3..f3ae4fb 100644
--- a/python/pyarrow/pandas_compat.py
+++ b/python/pyarrow/pandas_compat.py
@@ -648,6 +648,7 @@ _pandas_logical_type_map = {
     'string': np.str_,
     'empty': np.object_,
     'mixed': np.object_,
+    'mixed-integer': np.object_
 }
 
 
diff --git a/python/pyarrow/tests/test_convert_pandas.py b/python/pyarrow/tests/test_convert_pandas.py
index 6bdbcca..81f2177 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -1818,7 +1818,7 @@ class TestConvertMisc(object):
         (np.object, pa.binary()),
         (np.object, pa.binary(10)),
         (np.object, pa.list_(pa.int64())),
-        ]
+    ]
 
     def test_all_none_objects(self):
         df = pd.DataFrame({'a': [None, None, None]})
@@ -1985,6 +1985,12 @@ class TestConvertMisc(object):
         arr = pa.array(data['y'], type=pa.int16())
         assert arr.to_pylist() == [-1, 2]
 
+    def test_mixed_integer_columns(self):
+        row = [[], []]
+        df = pd.DataFrame(data=[row], columns=['foo', 123])
+        expected_df = pd.DataFrame(data=[row], columns=['foo', '123'])
+        _check_pandas_roundtrip(df, expected=expected_df, preserve_index=True)
+
 
 def _fully_loaded_dataframe_example():
     from distutils.version import LooseVersion

-- 
To stop receiving notification emails like this one, please contact
uwe@apache.org.