File tree 1 file changed +5
-13
lines changed
1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -140,10 +140,7 @@ def infer_freq(
140
140
>>> pd.infer_freq(idx)
141
141
'D'
142
142
"""
143
- from pandas .core .api import (
144
- DatetimeIndex ,
145
- Index ,
146
- )
143
+ from pandas .core .api import DatetimeIndex
147
144
148
145
if isinstance (index , ABCSeries ):
149
146
values = index ._values
@@ -172,15 +169,10 @@ def infer_freq(
172
169
inferer = _TimedeltaFrequencyInferer (index )
173
170
return inferer .get_freq ()
174
171
175
- if isinstance (index , Index ) and not isinstance (index , DatetimeIndex ):
176
- if is_numeric_dtype (index .dtype ):
177
- raise TypeError (
178
- f"cannot infer freq from a non-convertible index of dtype { index .dtype } "
179
- )
180
- # error: Incompatible types in assignment (expression has type
181
- # "Union[ExtensionArray, ndarray[Any, Any]]", variable has type
182
- # "Union[DatetimeIndex, TimedeltaIndex, Series, DatetimeLikeArrayMixin]")
183
- index = index ._values # type: ignore[assignment]
172
+ elif is_numeric_dtype (index .dtype ):
173
+ raise TypeError (
174
+ f"cannot infer freq from a non-convertible index of dtype { index .dtype } "
175
+ )
184
176
185
177
if not isinstance (index , DatetimeIndex ):
186
178
index = DatetimeIndex (index )
You can’t perform that action at this time.
0 commit comments