Write a NumPy program to split of an array of shape 4x4 it into two arrays along the second axis
- برمجة بايثون
- 2021-09-12
- mhanasmh00489829403
الأجوبة
import numpy as np
x = np.arange(16).reshape((4, 4))
print("Original array:",x)
print("After splitting horizontally:")
print(np.hsplit(x, [2, 6]))
Sample Output:
Original array: [[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]
[12 13 14 15]]
After splitting horizontally:
[array([[ 0, 1],
[ 4, 5],
[ 8, 9],
[12, 13]]), array([[ 2, 3],
[ 6, 7],
[10, 11],
[14, 15]]), array([], shape=(4, 0), dtype=int64)]أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال