33import datetime
44from functools import partial
55from textwrap import dedent
6- from typing import (
7- TYPE_CHECKING ,
8- cast ,
9- )
6+ from typing import TYPE_CHECKING
107import warnings
118
129import numpy as np
@@ -106,7 +103,7 @@ def get_center_of_mass(
106103
107104
108105def _calculate_deltas (
109- times : str | np .ndarray | NDFrame | None ,
106+ times : np .ndarray | NDFrame ,
110107 halflife : float | TimedeltaConvertibleTypes | None ,
111108) -> np .ndarray :
112109 """
@@ -115,7 +112,7 @@ def _calculate_deltas(
115112
116113 Parameters
117114 ----------
118- times : str, np.ndarray, Series, default None
115+ times : np.ndarray, Series
119116 Times corresponding to the observations. Must be monotonically increasing
120117 and ``datetime64[ns]`` dtype.
121118 halflife : float, str, timedelta, optional
@@ -126,13 +123,7 @@ def _calculate_deltas(
126123 np.ndarray
127124 Diff of the times divided by the half-life
128125 """
129- # error: Item "str" of "Union[str, ndarray, NDFrameT, None]" has no
130- # attribute "view"
131- # error: Item "None" of "Union[str, ndarray, NDFrameT, None]" has no
132- # attribute "view"
133- _times = np .asarray (
134- times .view (np .int64 ), dtype = np .float64 # type: ignore[union-attr]
135- )
126+ _times = np .asarray (times .view (np .int64 ), dtype = np .float64 )
136127 # TODO: generalize to non-nano?
137128 _halflife = float (Timedelta (halflife )._as_unit ("ns" ).value )
138129 return np .diff (_times ) / _halflife
@@ -221,7 +212,7 @@ class ExponentialMovingWindow(BaseWindow):
221212
222213 For `Series` this parameter is unused and defaults to 0.
223214
224- times : str, np.ndarray, Series, default None
215+ times : np.ndarray, Series, default None
225216
226217 .. versionadded:: 1.1.0
227218
@@ -232,9 +223,6 @@ class ExponentialMovingWindow(BaseWindow):
232223
233224 If 1-D array like, a sequence with the same shape as the observations.
234225
235- .. deprecated:: 1.4.0
236- If str, the name of the column in the DataFrame representing the times.
237-
238226 method : str {'single', 'table'}, default 'single'
239227 .. versionadded:: 1.4.0
240228
@@ -359,7 +347,7 @@ def __init__(
359347 adjust : bool = True ,
360348 ignore_na : bool = False ,
361349 axis : Axis = 0 ,
362- times : str | np .ndarray | NDFrame | None = None ,
350+ times : np .ndarray | NDFrame | None = None ,
363351 method : str = "single" ,
364352 * ,
365353 selection = None ,
@@ -384,18 +372,6 @@ def __init__(
384372 if self .times is not None :
385373 if not self .adjust :
386374 raise NotImplementedError ("times is not supported with adjust=False." )
387- if isinstance (self .times , str ):
388- warnings .warn (
389- (
390- "Specifying times as a string column label is deprecated "
391- "and will be removed in a future version. Pass the column "
392- "into times instead."
393- ),
394- FutureWarning ,
395- stacklevel = find_stack_level (),
396- )
397- # self.times cannot be str anymore
398- self .times = cast ("Series" , self ._selected_obj [self .times ])
399375 if not is_datetime64_ns_dtype (self .times ):
400376 raise ValueError ("times must be datetime64[ns] dtype." )
401377 if len (self .times ) != len (obj ):
@@ -897,7 +873,7 @@ def __init__(self, obj, *args, _grouper=None, **kwargs) -> None:
897873 # sort the times and recalculate the deltas according to the groups
898874 groupby_order = np .concatenate (list (self ._grouper .indices .values ()))
899875 self ._deltas = _calculate_deltas (
900- self .times .take (groupby_order ), # type: ignore[union-attr]
876+ self .times .take (groupby_order ),
901877 self .halflife ,
902878 )
903879
@@ -928,7 +904,7 @@ def __init__(
928904 adjust : bool = True ,
929905 ignore_na : bool = False ,
930906 axis : Axis = 0 ,
931- times : str | np .ndarray | NDFrame | None = None ,
907+ times : np .ndarray | NDFrame | None = None ,
932908 engine : str = "numba" ,
933909 engine_kwargs : dict [str , bool ] | None = None ,
934910 * ,
0 commit comments