arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [arrow] branch master updated: ARROW-1890: [Python] Fix mask handling for Date32 NumPy conversions
Date Wed, 06 Dec 2017 16:00:52 GMT
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 665da71  ARROW-1890: [Python] Fix mask handling for Date32 NumPy conversions
665da71 is described below

commit 665da71c7d73feba6f435e96c22d90b6632a8ad1
Author: Uwe L. Korn <uwelk@xhochy.com>
AuthorDate: Wed Dec 6 17:00:45 2017 +0100

    ARROW-1890: [Python] Fix mask handling for Date32 NumPy conversions
    
    Author: Uwe L. Korn <uwelk@xhochy.com>
    
    Closes #1393 from xhochy/ARROW-1890 and squashes the following commits:
    
    7ef92ea [Uwe L. Korn] ARROW-1890: [Python] Fix mask handling for Date32 NumPy conversions
---
 cpp/src/arrow/python/numpy_to_arrow.cc      | 1 +
 python/pyarrow/tests/test_convert_pandas.py | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/cpp/src/arrow/python/numpy_to_arrow.cc b/cpp/src/arrow/python/numpy_to_arrow.cc
index 2316a79..bcaccc7 100644
--- a/cpp/src/arrow/python/numpy_to_arrow.cc
+++ b/cpp/src/arrow/python/numpy_to_arrow.cc
@@ -120,6 +120,7 @@ int64_t MaskToBitmap(PyArrayObject* mask, int64_t length, uint8_t* bitmap)
{
   for (int i = 0; i < length; ++i) {
     if (mask_values[i]) {
       ++null_count;
+      BitUtil::ClearBit(bitmap, i);
     } else {
       BitUtil::SetBit(bitmap, i);
     }
diff --git a/python/pyarrow/tests/test_convert_pandas.py b/python/pyarrow/tests/test_convert_pandas.py
index a2a1d6b..a43651e 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -572,6 +572,15 @@ class TestPandasConversion(object):
         expected['date'] = pd.to_datetime(df['date'])
         tm.assert_frame_equal(result, expected)
 
+    def test_date_mask(self):
+        arr = np.array([date(2017, 4, 3), date(2017, 4, 4)],
+                       dtype='datetime64[D]')
+        mask = [True, False]
+        result = pa.array(arr, mask=np.array(mask))
+        expected = np.array([None, date(2017, 4, 4)], dtype='datetime64[D]')
+        expected = pa.array(expected, from_pandas=True)
+        assert expected.equals(result)
+
     def test_date_objects_typed(self):
         arr = np.array([
             date(2017, 4, 3),

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

Mime
View raw message