Saved Bookmarks
| 1. |
What happens when the split() method is used for splitting NumPy arrays? |
|
Answer» 1. np.split() : Equally splits arrays into multiple sub-arrays. It raises Value Error when the split cannot be equal.
where,
a = np.arange(8) split_arr = np.split(a, 2) split_arr Output [array([0, 1, 2, 3]), array([4, 5, 6, 7])]
array([3.]), array([4.]), array([5.]), array([], dtype=float64), array([], dtype=float64), array([], dtype=float64)] The output would be: import numpy as npa = np.arange(6.0) split_arr = np.split(a, [3, 4, 5, 6, 7,8]) split_arr
|
|