Say I do the following:
my_array = np.array([[1,2,3]])
my_new_array = np.delete(my_array, [])
The last line will convert my_array to:
my_new_array = np.array([1,2,3]) # It flattens the array one level
which is not what I expected.
If instead I had had:
my_array = np.array([[1,2,3], [4,5,6]])
my_new_array = np.delete(my_array, [])
I would get:
my_new_array = np.array([[1,2,3], [4,5,6]])
which is what I expect. How can I make sure a call to np.delete(my_array, []) does not flattens my array?
From the documentation:
Because you are not supplying anything to
axis, it is flattening the array. You could do the following:Which seems to be the result that you want. However, it is unclear why you want to apply a transformation that gives you the same array.