@@ -3284,97 +3284,6 @@ def test_safe_cast_from_float_with_nans_to_int():
32843284 assert arr .equals (expected )
32853285
32863286
3287- def test_create_date32_and_date64_arrays_with_mask ():
3288- # Test Date32 array creation from Python list with mask
3289- arr_date32 = pa .array ([0 , 0 , 1 , 2 ],
3290- mask = [False , False , True , False ],
3291- type = pa .date32 ())
3292- expected_date32 = pa .array ([
3293- date (1970 , 1 , 1 ),
3294- date (1970 , 1 , 1 ),
3295- None ,
3296- date (1970 , 1 , 3 ),
3297- ], type = pa .date32 ())
3298- assert arr_date32 .equals (expected_date32 )
3299-
3300- # Test Date32 array creation from Python dates
3301- arr_date32_dates = pa .array ([
3302- date (2023 , 1 , 1 ),
3303- date (2023 , 1 , 2 ),
3304- None ,
3305- date (2023 , 1 , 4 ),
3306- ], type = pa .date32 ())
3307- assert arr_date32_dates .null_count == 1
3308- assert arr_date32_dates [2 ].as_py () is None
3309-
3310- # Test Date64 array creation from Python list with mask
3311- arr_date64 = pa .array ([0 , 86400000 , 172800000 , 259200000 ],
3312- mask = [False , False , True , False ],
3313- type = pa .date64 ())
3314- expected_date64 = pa .array ([
3315- date (1970 , 1 , 1 ),
3316- date (1970 , 1 , 2 ),
3317- None ,
3318- date (1970 , 1 , 4 ),
3319- ], type = pa .date64 ())
3320- assert arr_date64 .equals (expected_date64 )
3321-
3322- # Test Date64 array creation from Python dates
3323- arr_date64_dates = pa .array ([
3324- date (2023 , 1 , 1 ),
3325- date (2023 , 1 , 2 ),
3326- None ,
3327- date (2023 , 1 , 4 ),
3328- ], type = pa .date64 ())
3329- assert arr_date64_dates .null_count == 1
3330- assert arr_date64_dates [2 ].as_py () is None
3331-
3332- # Test Date32 with all nulls mask
3333- arr_all_null = pa .array ([0 , 1 , 2 , 3 ],
3334- mask = [True , True , True , True ],
3335- type = pa .date32 ())
3336- assert arr_all_null .null_count == 4
3337-
3338- # Test Date64 with no nulls
3339- arr_no_null = pa .array ([0 , 86400000 , 172800000 ],
3340- mask = [False , False , False ],
3341- type = pa .date64 ())
3342- assert arr_no_null .null_count == 0
3343-
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-
3377-
33783287def _fully_loaded_dataframe_example ():
33793288 index = pd .MultiIndex .from_arrays ([
33803289 pd .date_range ('2000-01-01' , periods = 5 ).repeat (2 ),
0 commit comments