sgilmore10 opened a new pull request, #47116:
URL: https://github.com/apache/arrow/pull/47116

   ### Rationale for this change
   
   It would be nice if there was a `NumNulls` property on the 
`arrow.array.Array` base class. Currently, the only way to figure out the 
number of nulls is count the number of `false` values in the `Valid` array:
   
   ```matlab
   >> a = arrow.array([1 2 NaN 4 5 6 NaN 8 9 10 NaN]);
   >> invalidValues = ~a.Valid;
   >> numNulls = nnz(invalidValues)
   
   numNulls =
   
        3
   ```
   
   It would be nice if `NumNulls` was already a property on the array class. As 
@kou mentioned, we can use the `arrow::Array::null_count()` to get the number 
of nulls.
   
   ### What changes are included in this PR?
   
   Added `NumNulls` as a property of the `arrow.array.Array` abstract class. 
`NumNulls` is a scalar `int64` value that returns the number of null elements 
in the array.
   
   **Example Usage**
   ```matlab
   >> a  = arrow.array([1 2 NaN 3 4 NaN 5 6 NaN])
   
   a = 
   
     Float64Array with 9 elements and 3 null values:
   
       1 | 2 | null | ... | 5 | 6 | null
   
   >> a.NumNulls 
   
   ans =
   
     int64
   
      3
   ```
   
   ### Are these changes tested?
   
   Yes. Added test cases verifying the `NumNulls` property to these MATLAB test 
classes: `hNumeric`, `tBooleanArray`, `tTimestampArray`, `tTime32Array`, 
`tTime64Array`, `tDate32Array`, `tDate64Array`, `tListArray`, `tStringArray`, 
and `tStructArray`.
   
   ### Are there any user-facing changes?
   
   Yes.  Users can now use the `NumNulls` property to query the number of null 
elements in an array.
   
   ### Future Changes
   
   1. Add `NumNulls` as a property of `arrow.array.ChunkedArray`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to