Please use `shift` from the `scipy.ndimage` namespace, the `scipy.ndimage.interpolation` namespace is deprecated. from scipy.ndimage.interpolation import shift
时间: 2023-08-16 08:11:29 浏览: 434
详解利用Python scipy.signal.filtfilt() 实现信号滤波
5星 · 资源好评率100%
Sure, you can use the `shift` function from the `scipy.ndimage` namespace instead of the deprecated `scipy.ndimage.interpolation` namespace. Here's how you can import and use it:
```python
from scipy.ndimage import shift
# Example usage
arr = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
shifted_arr = shift(arr, (1, 1))
print(shifted_arr)
```
This will shift the array `arr` by one position in both the horizontal and vertical directions. The output will be:
```
[[0 0 0]
[0 1 2]
[0 4 5]]
```
Note that the `shift` function takes the array as the first argument and a tuple `(shift_x, shift_y)` as the second argument to specify the amount of shift in each direction.
阅读全文