11from datetime import datetime , timedelta
22import inspect
33import re
4- from typing import Any , List
4+ from typing import TYPE_CHECKING , Any , List , Optional
55import warnings
66
77import numpy as np
8383import pandas .core .missing as missing
8484from pandas .core .nanops import nanpercentile
8585
86+ if TYPE_CHECKING :
87+ from pandas import Index
88+
8689
8790class Block (PandasObject ):
8891 """
@@ -1066,16 +1069,16 @@ def coerce_to_target_dtype(self, other):
10661069
10671070 def interpolate (
10681071 self ,
1069- method = "pad" ,
1070- axis = 0 ,
1071- index = None ,
1072- inplace = False ,
1073- limit = None ,
1074- limit_direction = "forward" ,
1075- limit_area = None ,
1076- fill_value = None ,
1077- coerce = False ,
1078- downcast = None ,
1072+ method : str = "pad" ,
1073+ axis : int = 0 ,
1074+ index : Optional [ "Index" ] = None ,
1075+ inplace : bool = False ,
1076+ limit : Optional [ int ] = None ,
1077+ limit_direction : str = "forward" ,
1078+ limit_area : Optional [ str ] = None ,
1079+ fill_value : Optional [ Any ] = None ,
1080+ coerce : bool = False ,
1081+ downcast : Optional [ str ] = None ,
10791082 ** kwargs ,
10801083 ):
10811084
@@ -1115,6 +1118,9 @@ def check_int_bool(self, inplace):
11151118 r = check_int_bool (self , inplace )
11161119 if r is not None :
11171120 return r
1121+
1122+ assert index is not None # for mypy
1123+
11181124 return self ._interpolate (
11191125 method = m ,
11201126 index = index ,
@@ -1130,13 +1136,13 @@ def check_int_bool(self, inplace):
11301136
11311137 def _interpolate_with_fill (
11321138 self ,
1133- method = "pad" ,
1134- axis = 0 ,
1135- inplace = False ,
1136- limit = None ,
1137- fill_value = None ,
1138- coerce = False ,
1139- downcast = None ,
1139+ method : str = "pad" ,
1140+ axis : int = 0 ,
1141+ inplace : bool = False ,
1142+ limit : Optional [ int ] = None ,
1143+ fill_value : Optional [ Any ] = None ,
1144+ coerce : bool = False ,
1145+ downcast : Optional [ str ] = None ,
11401146 ) -> List ["Block" ]:
11411147 """ fillna but using the interpolate machinery """
11421148 inplace = validate_bool_kwarg (inplace , "inplace" )
@@ -1169,15 +1175,15 @@ def _interpolate_with_fill(
11691175
11701176 def _interpolate (
11711177 self ,
1172- method = None ,
1173- index = None ,
1174- fill_value = None ,
1175- axis = 0 ,
1176- limit = None ,
1177- limit_direction = "forward" ,
1178- limit_area = None ,
1179- inplace = False ,
1180- downcast = None ,
1178+ method : str ,
1179+ index : "Index" ,
1180+ fill_value : Optional [ Any ] = None ,
1181+ axis : int = 0 ,
1182+ limit : Optional [ int ] = None ,
1183+ limit_direction : str = "forward" ,
1184+ limit_area : Optional [ str ] = None ,
1185+ inplace : bool = False ,
1186+ downcast : Optional [ str ] = None ,
11811187 ** kwargs ,
11821188 ) -> List ["Block" ]:
11831189 """ interpolate using scipy wrappers """
@@ -1200,14 +1206,14 @@ def _interpolate(
12001206 )
12011207 # process 1-d slices in the axis direction
12021208
1203- def func (x ) :
1209+ def func (yvalues : np . ndarray ) -> np . ndarray :
12041210
12051211 # process a 1-d slice, returning it
12061212 # should the axis argument be handled below in apply_along_axis?
12071213 # i.e. not an arg to missing.interpolate_1d
12081214 return missing .interpolate_1d (
1209- index ,
1210- x ,
1215+ xvalues = index ,
1216+ yvalues = yvalues ,
12111217 method = method ,
12121218 limit = limit ,
12131219 limit_direction = limit_direction ,
0 commit comments