(method, index: Index)
| 326 | |
| 327 | |
| 328 | def get_interp_index(method, index: Index) -> Index: |
| 329 | # create/use the index |
| 330 | if method == "linear": |
| 331 | # prior default |
| 332 | from pandas import RangeIndex |
| 333 | |
| 334 | index = RangeIndex(len(index)) |
| 335 | else: |
| 336 | methods = {"index", "values", "nearest", "time"} |
| 337 | is_numeric_or_datetime = ( |
| 338 | is_numeric_dtype(index.dtype) |
| 339 | or isinstance(index.dtype, DatetimeTZDtype) |
| 340 | or lib.is_np_dtype(index.dtype, "mM") |
| 341 | ) |
| 342 | valid = NP_METHODS + SP_METHODS |
| 343 | if method in valid: |
| 344 | if method not in methods and not is_numeric_or_datetime: |
| 345 | raise ValueError( |
| 346 | "Index column must be numeric or datetime type when " |
| 347 | f"using {method} method other than linear. " |
| 348 | "Try setting a numeric or datetime index column before " |
| 349 | "interpolating." |
| 350 | ) |
| 351 | else: |
| 352 | raise ValueError(f"Can not interpolate with method={method}.") |
| 353 | |
| 354 | if isna(index).any(): |
| 355 | raise NotImplementedError( |
| 356 | "Interpolation with NaNs in the index " |
| 357 | "has not been implemented. Try filling " |
| 358 | "those NaNs before interpolating." |
| 359 | ) |
| 360 | return index |
| 361 | |
| 362 | |
| 363 | def interpolate_2d_inplace( |
nothing calls this directly
no test coverage detected