arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [arrow] branch master updated: ARROW-1743: [Python] Avoid non-array writeable-flag check
Date Tue, 14 Nov 2017 03:47:28 GMT
This is an automated email from the ASF dual-hosted git repository.

wesm 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 6f8e287  ARROW-1743: [Python] Avoid non-array writeable-flag check
6f8e287 is described below

commit 6f8e2873c3931ff279b05a5e517a87637eb13d05
Author: Licht-T <licht-t@outlook.jp>
AuthorDate: Mon Nov 13 22:47:22 2017 -0500

    ARROW-1743: [Python] Avoid non-array writeable-flag check
    
    This closes [ARROW-1743](https://issues.apache.org/jira/projects/ARROW/issues/ARROW-1743).
    
    Author: Licht-T <licht-t@outlook.jp>
    
    Closes #1260 from Licht-T/fix-non-array-writable-check and squashes the following commits:
    
    8a104f7c [Licht-T] TST: Add test_categorical_row_index
    555acdeb [Licht-T] BUG: Avoid the writeable-flag check for non-array index
---
 python/pyarrow/pandas_compat.py             | 2 +-
 python/pyarrow/tests/test_convert_pandas.py | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/python/pyarrow/pandas_compat.py b/python/pyarrow/pandas_compat.py
index db28ee0..41eaf0b 100644
--- a/python/pyarrow/pandas_compat.py
+++ b/python/pyarrow/pandas_compat.py
@@ -397,7 +397,7 @@ def table_to_blockmanager(options, table, memory_pool, nthreads=1):
             col = table.column(i)
             col_pandas = col.to_pandas()
             values = col_pandas.values
-            if not values.flags.writeable:
+            if hasattr(values, 'flags') and not values.flags.writeable:
                 # ARROW-1054: in pandas 0.19.2, factorize will reject
                 # non-writeable arrays when calling MultiIndex.from_arrays
                 values = values.copy()
diff --git a/python/pyarrow/tests/test_convert_pandas.py b/python/pyarrow/tests/test_convert_pandas.py
index dabccac..b9c3a12 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -198,6 +198,13 @@ class TestPandasConversion(object):
         md = column_indexes['metadata']
         assert md['timezone'] == 'America/New_York'
 
+    def test_categorical_row_index(self):
+        df = pd.DataFrame({'a': [1, 2, 3], 'b': [1, 2, 3]})
+        df['a'] = df.a.astype('category')
+        df = df.set_index('a')
+
+        self._check_pandas_roundtrip(df, preserve_index=True)
+
     def test_float_no_nulls(self):
         data = {}
         fields = []

-- 
To stop receiving notification emails like this one, please contact
['"commits@arrow.apache.org" <commits@arrow.apache.org>'].

Mime
View raw message