Uncertainity About The Interpolate Function In Pandas
I am working with the interpolate function in pandas. Here is a toy example to make an illustrative case: df=pd.DataFrame({'Data':np.random.normal(size=200), 'Data2':np.random.norm
Solution 1:
The docs reference the various available methods - most just rely on the index
, possibly via the univariate scipy.interp1d
or other univariate scipy
methods:
method : {‘linear’, ‘time’, ‘index’, ‘values’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘krogh’, ‘polynomial’, ‘spline’ ‘piecewise_polynomial’, ‘pchip’}
- ‘linear’: ignore the index and treat the values as equally spaced. This is the only method supported on MultiIndexes.
- default ‘time’: interpolation works on daily and higher resolution data to interpolate given length of interval ‘index’, ‘values’: use the actual numerical values of the index
- ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘polynomial’ is passed to scipy.interpolate.interp1d. Both ‘polynomial’ and ‘spline’ require that you also specify an order (int), e.g. df.interpolate(method=’polynomial’, order=4). These use the actual numerical values of the index.
- ‘krogh’, ‘piecewise_polynomial’, ‘spline’, and ‘pchip’ are all wrappers around the scipy interpolation methods of similar names. These use the actual numerical values of the index.
Scipy docs and charts illustrating output here
Post a Comment for "Uncertainity About The Interpolate Function In Pandas"