3
3
import datetime
4
4
from functools import partial
5
5
from textwrap import dedent
6
- from typing import (
7
- TYPE_CHECKING ,
8
- cast ,
9
- )
6
+ from typing import TYPE_CHECKING
10
7
import warnings
11
8
12
9
import numpy as np
@@ -106,7 +103,7 @@ def get_center_of_mass(
106
103
107
104
108
105
def _calculate_deltas (
109
- times : str | np .ndarray | NDFrame | None ,
106
+ times : np .ndarray | NDFrame ,
110
107
halflife : float | TimedeltaConvertibleTypes | None ,
111
108
) -> np .ndarray :
112
109
"""
@@ -115,7 +112,7 @@ def _calculate_deltas(
115
112
116
113
Parameters
117
114
----------
118
- times : str, np.ndarray, Series, default None
115
+ times : np.ndarray, Series
119
116
Times corresponding to the observations. Must be monotonically increasing
120
117
and ``datetime64[ns]`` dtype.
121
118
halflife : float, str, timedelta, optional
@@ -126,13 +123,7 @@ def _calculate_deltas(
126
123
np.ndarray
127
124
Diff of the times divided by the half-life
128
125
"""
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 )
136
127
# TODO: generalize to non-nano?
137
128
_halflife = float (Timedelta (halflife )._as_unit ("ns" ).value )
138
129
return np .diff (_times ) / _halflife
@@ -221,7 +212,7 @@ class ExponentialMovingWindow(BaseWindow):
221
212
222
213
For `Series` this parameter is unused and defaults to 0.
223
214
224
- times : str, np.ndarray, Series, default None
215
+ times : np.ndarray, Series, default None
225
216
226
217
.. versionadded:: 1.1.0
227
218
@@ -232,9 +223,6 @@ class ExponentialMovingWindow(BaseWindow):
232
223
233
224
If 1-D array like, a sequence with the same shape as the observations.
234
225
235
- .. deprecated:: 1.4.0
236
- If str, the name of the column in the DataFrame representing the times.
237
-
238
226
method : str {'single', 'table'}, default 'single'
239
227
.. versionadded:: 1.4.0
240
228
@@ -359,7 +347,7 @@ def __init__(
359
347
adjust : bool = True ,
360
348
ignore_na : bool = False ,
361
349
axis : Axis = 0 ,
362
- times : str | np .ndarray | NDFrame | None = None ,
350
+ times : np .ndarray | NDFrame | None = None ,
363
351
method : str = "single" ,
364
352
* ,
365
353
selection = None ,
@@ -384,18 +372,6 @@ def __init__(
384
372
if self .times is not None :
385
373
if not self .adjust :
386
374
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 ])
399
375
if not is_datetime64_ns_dtype (self .times ):
400
376
raise ValueError ("times must be datetime64[ns] dtype." )
401
377
if len (self .times ) != len (obj ):
@@ -897,7 +873,7 @@ def __init__(self, obj, *args, _grouper=None, **kwargs) -> None:
897
873
# sort the times and recalculate the deltas according to the groups
898
874
groupby_order = np .concatenate (list (self ._grouper .indices .values ()))
899
875
self ._deltas = _calculate_deltas (
900
- self .times .take (groupby_order ), # type: ignore[union-attr]
876
+ self .times .take (groupby_order ),
901
877
self .halflife ,
902
878
)
903
879
@@ -928,7 +904,7 @@ def __init__(
928
904
adjust : bool = True ,
929
905
ignore_na : bool = False ,
930
906
axis : Axis = 0 ,
931
- times : str | np .ndarray | NDFrame | None = None ,
907
+ times : np .ndarray | NDFrame | None = None ,
932
908
engine : str = "numba" ,
933
909
engine_kwargs : dict [str , bool ] | None = None ,
934
910
* ,
0 commit comments