[
https://issues.apache.org/jira/browse/ARROW-1890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16280369#comment-16280369
]
ASF GitHub Bot commented on ARROW-1890:
---------------------------------------
xhochy closed pull request #1393: ARROW-1890: [Python] Fix mask handling for
Date32 NumPy conversions
URL: https://github.com/apache/arrow/pull/1393
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cpp/src/arrow/python/numpy_to_arrow.cc
b/cpp/src/arrow/python/numpy_to_arrow.cc
index 2316a796a..bcaccc734 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 a2a1d6b69..a43651ed9 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -572,6 +572,15 @@ def test_date_infer(self):
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),
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Masking for date32 arrays not working
> ----------------------------------------------
>
> Key: ARROW-1890
> URL: https://issues.apache.org/jira/browse/ARROW-1890
> Project: Apache Arrow
> Issue Type: Bug
> Reporter: Uwe L. Korn
> Assignee: Uwe L. Korn
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> {code}
> arr = np.array([date(2017, 4, 3), date(2017, 4, 4)], dtype='datetime64[D]')
> mask = [True, False]
> t32 = pa.date32()
> result = pa.array(arr, mask=np.array(mask))
> expected = pa.array(np.array([None, date(2017, 4, 4)], dtype='datetime64[D]'))
> {code}
> The above code produces an array that has no null values.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)