Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:12:53+00:00 2026-06-16T00:12:53+00:00

Say I do the following: my_array = np.array([[1,2,3]]) my_new_array = np.delete(my_array, []) The last

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:12:54+00:00Added an answer on June 16, 2026 at 12:12 am

    From the documentation:

    numpy.delete(arr, obj, axis=None)

    axis : int, optional

    The axis along which to delete the subarray defined by obj. If axis is None, obj is applied to the flattened array

    Because you are not supplying anything to axis, it is flattening the array. You could do the following:

    >>> print np.delete(my_array, [], axis=0)
    array([[1, 2, 3],
           [4, 5, 6]])
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The perldocs say the following about last : last cannot be used to exit
Say I have an array of chars, which I have allocated on the heap,
Let's say I have following ArrayObject : $array_object = new ArrayObject(array( array('1', '2', '3',
Say I have the following 2d array in Java set to a variable named
First of all i have the following to convert my Javascript array to a
Let's say I have the following array: [['a'],['b'],['c']] I would like to create 3
Let's say I have the following in my HTML code: <select name=Currency id=Currency> <option
Say I have the following string: hello my car is red and my shoe
Say I have the following DOM element in my piece of code: <div id=test>
say I have the following <h3>This is my heading</h3> <p>This is my headingAnd this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.