![]() |
VOOZH | about |
NumPy is the Python library that is used for working with arrays. In Python there are lists which serve the purpose of arrays but they are slow. Therefore, NumPy is there to provide us with the array object that is much faster than the traditional Python lists. The reason for them being faster is that they store arrays at one continuous place in memory, unlike lists which makes the process accessing and manipulation much more efficient.
There are a number of ways to delete multiple rows in NumPy array. They are given below :-
Using arrays of ints, Syntax: np.delete(x, [ 0, 2, 3], axis=0)
Output:
[[15 16 17 18 19] [20 21 22 23 24] [25 26 27 28 29] [30 31 32 33 34]]
Using slice objects – The slice() function allows us to specify how to slice a sequence.
Syntax of slice function: slice(start, stop, step index)
Output:
[[15 16 17 18 19] [20 21 22 23 24] [25 26 27 28 29] [30 31 32 33 34]]
Output:
[[20 21 22 23 24] [25 26 27 28 29] [30 31 32 33 34]]
Output:
[[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14]]
Output:
[[ 0 1 2 3 4] [10 11 12 13 14] [30 31 32 33 34]]
Output:
[[0 1 2 3 4] [5 6 7 8 9]]