@@ -3341,6 +3341,39 @@ def test_create_date32_and_date64_arrays_with_mask():
33413341 type = pa .date64 ())
33423342 assert arr_no_null .null_count == 0
33433343
3344+ # Test Date32 from NumPy datetime64[D] array with mask
3345+ arr_np_date32 = np .array ([0 , 1 , 2 , 3 ], dtype = 'datetime64[D]' )
3346+ mask_np_date32 = np .array ([False , False , True , False ])
3347+ result_np_date32 = pa .array (arr_np_date32 ,
3348+ mask = mask_np_date32 ,
3349+ type = pa .date32 ())
3350+ expected_np_date32 = pa .array ([
3351+ date (1970 , 1 , 1 ),
3352+ date (1970 , 1 , 2 ),
3353+ None ,
3354+ date (1970 , 1 , 4 ),
3355+ ], type = pa .date32 ())
3356+ assert result_np_date32 .equals (expected_np_date32 )
3357+ assert result_np_date32 .null_count == 1
3358+ assert result_np_date32 [2 ].as_py () is None
3359+
3360+ # Test Date64 from NumPy datetime64[ms] array with mask
3361+ arr_np_date64 = np .array (
3362+ [0 , 86400000 , 172800000 , 259200000 ], dtype = 'datetime64[ms]' )
3363+ mask_np_date64 = np .array ([False , True , False , False ])
3364+ result_np_date64 = pa .array (arr_np_date64 ,
3365+ mask = mask_np_date64 ,
3366+ type = pa .date64 ())
3367+ expected_np_date64 = pa .array ([
3368+ date (1970 , 1 , 1 ),
3369+ None ,
3370+ date (1970 , 1 , 3 ),
3371+ date (1970 , 1 , 4 ),
3372+ ], type = pa .date64 ())
3373+ assert result_np_date64 .equals (expected_np_date64 )
3374+ assert result_np_date64 .null_count == 1
3375+ assert result_np_date64 [1 ].as_py () is None
3376+
33443377
33453378def _fully_loaded_dataframe_example ():
33463379 index = pd .MultiIndex .from_arrays ([
0 commit comments