@@ -161,7 +161,7 @@ def apply_map(func: Callable[[Any], Any], array: Union[List, np.ndarray]) -> np.
161161#############################
162162
163163
164- def nans (shape : Union [int , Tuple [int , ...]], dtype = np . float64 ) -> np .ndarray :
164+ def nans (shape : Union [int , Tuple [int , ...]], dtype = float ) -> np .ndarray :
165165 """
166166 Return a new array of a given shape and type, filled with np.nan values.
167167
@@ -187,9 +187,12 @@ def nans(shape: Union[int, Tuple[int, ...]], dtype=np.float64) -> np.ndarray:
187187 array(['NaT', 'NaT'], dtype=datetime64)
188188 """
189189 if np .issubdtype (dtype , np .integer ):
190- dtype = np . float
190+ dtype = float
191191 arr = np .empty (shape , dtype = dtype )
192- arr .fill (np .nan )
192+ if np .issubdtype (arr .dtype , np .datetime64 ):
193+ arr .fill (np .datetime64 ('NaT' ))
194+ else :
195+ arr .fill (np .nan )
193196 return arr
194197
195198
@@ -292,7 +295,7 @@ def prepend_na(array: np.ndarray, n: int) -> np.ndarray:
292295 return np .hstack ((nans (n ), array ))
293296
294297 elem = array [0 ]
295- dtype = np . float64
298+ dtype = float
296299 if hasattr (elem , 'dtype' ):
297300 dtype = elem .dtype
298301
@@ -494,7 +497,7 @@ def rows_gen():
494497
495498 yield from (array [:i ] for i in np .arange (min_periods , array .size + 1 ))
496499
497- return np .array ([row for row in rows_gen ()]) if as_array else rows_gen ()
500+ return np .array ([row for row in rows_gen ()], dtype = object ) if as_array else rows_gen ()
498501
499502
500503def expanding_apply (
@@ -553,7 +556,7 @@ def expanding_apply(
553556 raise ValueError ('Arrays must be the same length' )
554557
555558 def _apply_func_to_arrays (idxs ):
556- return func (* [array [idxs .astype (np . int )] for array in arrays ], ** kwargs )
559+ return func (* [array [idxs .astype (int )] for array in arrays ], ** kwargs )
557560
558561 array = arrays [0 ]
559562 rolls = expanding (
0 commit comments