@@ -158,12 +158,12 @@ def _get_fill_value(dtype, fill_value):
158158 return np .nan
159159 # This is madness, but npg checks that fill_value is compatible
160160 # with array dtype even if the fill_value is never used.
161- elif (
162- np .issubdtype (dtype , np .integer )
163- or np .issubdtype (dtype , np .timedelta64 )
164- or np .issubdtype (dtype , np .datetime64 )
165- ):
161+ elif np .issubdtype (dtype , np .integer ):
166162 return dtypes .get_neg_infinity (dtype , min_for_int = True )
163+ elif np .issubdtype (dtype , np .timedelta64 ):
164+ return np .timedelta64 ("NaT" )
165+ elif np .issubdtype (dtype , np .datetime64 ):
166+ return np .datetime64 ("NaT" )
167167 else :
168168 return None
169169 return fill_value
@@ -435,9 +435,9 @@ def _std_finalize(sumsq, sum_, count, ddof=0):
435435
436436
437437min_ = Aggregation ("min" , chunk = "min" , combine = "min" , fill_value = dtypes .INF )
438- nanmin = Aggregation ("nanmin" , chunk = "nanmin" , combine = "nanmin" , fill_value = np . nan )
438+ nanmin = Aggregation ("nanmin" , chunk = "nanmin" , combine = "nanmin" , fill_value = dtypes . NA )
439439max_ = Aggregation ("max" , chunk = "max" , combine = "max" , fill_value = dtypes .NINF )
440- nanmax = Aggregation ("nanmax" , chunk = "nanmax" , combine = "nanmax" , fill_value = np . nan )
440+ nanmax = Aggregation ("nanmax" , chunk = "nanmax" , combine = "nanmax" , fill_value = dtypes . NA )
441441
442442
443443def argreduce_preprocess (array , axis ):
@@ -741,15 +741,15 @@ def scan_binary_op(left_state: ScanState, right_state: ScanState, *, agg: Scan)
741741 binary_op = None ,
742742 reduction = "nanlast" ,
743743 scan = "ffill" ,
744- identity = np . nan ,
744+ identity = dtypes . NA ,
745745 mode = "concat_then_scan" ,
746746)
747747bfill = Scan (
748748 "bfill" ,
749749 binary_op = None ,
750750 reduction = "nanlast" ,
751751 scan = "ffill" ,
752- identity = np . nan ,
752+ identity = dtypes . NA ,
753753 mode = "concat_then_scan" ,
754754 preprocess = reverse ,
755755 finalize = reverse ,
0 commit comments