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 9016547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:01:18+00:00 2026-06-16T04:01:18+00:00

I have a list of 2d numpy arrays. As a test, consider the following

  • 0

I have a list of 2d numpy arrays. As a test, consider the following list:

lst = [np.arange(10).reshape(5,2)]*10

Now I can get at a particular data element by:

lst[k][j,i]

I would like to convert this to a numpy array so that I can index it:

array[k,j,i]

i.e., the shape should be (10, 5, 2).

This seems to work, but seems completely unnecessary:

z = np.empty((10,5,2))
for i,x in enumerate(z):
    x[:,:] = lst[i]

These don’t work:

np.hstack(lst)
np.vstack(lst)
np.dstack(lst)  #this is closest, but gives wrong shape (5, 2, 10)

I suppose I could pair a np.dstack with a np.rollaxis, but again, that doesn’t seem quite right …

Is there a good way to do this with numpy?

I’ve looked at this very related post, but I can’t quite seem to work it out.

  • 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-16T04:01:19+00:00Added an answer on June 16, 2026 at 4:01 am

    This should work simply by calling the array constructor, i.e. np.array(lst).

    >>> l = [np.arange(10).reshape((5,2)) for i in range(10)]
    >>> np.array(l).shape
    (10, 5, 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of structure. I want to modify a particular data from the
If I have a list of numpy arrays, then using remove method returns a
I have a list of numpy arrays of different lengths, some of which repeat,
Say I have the following two lists/numpy arrays: List1 = [[1,2,3,4], [10,11,12], ...] List2
I have two arrays in numpy. The first is a 2d array, which can
I have a set of matrices as numpy 2d arrays in a list. They
Python question. I have a list (A) of numpy object arrays (B). I'd like
Suppose I have the following numpy arrays: >>a array([[0, 0, 2], [2, 0, 1],
I have list of words. I type in a word misspelled. Can I query
I have list of files which contain particular patterns, but those files have been

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.