Since that middle dimension is size 1, just reshape or squeeze it.

x = np.array(alist)
x = np.squeeze(x)  # or
x = x.reshape(45, 5785)  # or
x = x[:,0,:]

You can remove the extra layer of nesting in the list, but this kind of reshaping is so much easier with arrays.

Answer from hpaulj on Stack Overflow
๐ŸŒ
Moonbooks
moonbooks.org โ€บ Articles โ€บ How-to-convert-a-list-to-a-matrix-using-numpy-in-python-
How to convert a list to a matrix using numpy in python ?
July 27, 2020 - To convert a list of numbers to a matrix, as solution is to use the numpy function asarray(): illustration: ... This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. ... Developer in my spare time, Iโ€™m interested in Earth observation and satellite-based ...
Discussions

python - Converting list to numpy array - Stack Overflow
I have managed to load images in a folder using the command line sklearn: load_sample_images() I would now like to convert it to a numpy.ndarray format with float32 datatype I was able to convert i... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Converting List of Numpy Arrays to Numpy Matrix - Stack Overflow
I have a list of lists, lists which I would like to convert to a numpy matrix (which I would usually do by matrixA = np.matrix(lists). More on stackoverflow.com
๐ŸŒ stackoverflow.com
December 1, 2014
Python - convert list of lists into matrix - Stack Overflow
I am using python, I have a list which contains inside it group of lists how can I convert it into one matrix? ... Any idea? Thank you in advanced. ... Question has nothing to do with keras - kindly do not spam the tag (removed). ... import numpy as np list1 = [1,2,3] list2 = [1,5,9] list3 ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - how to convert 2d list to 2d numpy array? - Stack Overflow
the inner lists won't be converted to numpy arrays). Which totally makes sense as you cannot have a 2D array (matrix) with variable 2nd dimension. More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ list to matrix python
How to Convert List to Matrix in Python | Delft Stack
February 2, 2024 - The following code uses the asarray() function from the NumPy library to convert a list to an array or matrix in Python.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-program-to-construct-nm-matrix-from-list
Python Program to Construct n*m Matrix from List - GeeksforGeeks
July 23, 2025 - The numpy.reshape() function enables us to transform the list into a matrix with n rows and m columns, while keeping the total number of elements unchanged. ... import numpy as np a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] n, m = 3, 4 # Convert ...
๐ŸŒ
IncludeHelp
includehelp.com โ€บ python โ€บ how-to-convert-list-of-lists-to-numpy-array.aspx
How to Convert List of Lists to NumPy Array?
May 26, 2023 - # Import NumPy import numpy as np # Creating a nested list (list of lists) l = [[1, 2], [3, 4], [5, 6]] # Printing list of lists and its type print("List of lists (l):\n", l, "\n") print("Type of l:", type(l), "\n") # Converting list of lists to NumPy array arr = np.array(l) # Printing NumPy array print("Result: NumPy Array (arr):\n", arr, "\n") print("Type of arr:", type(arr), "\n")
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to convert a list to a numpy array?
How to Convert a List to a NumPy Array? - Be on the Right Side of Change
November 20, 2022 - The simplest way to convert a Python list to a NumPy array is to use the np.array() function that takes an iterable and returns a NumPy array.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-python-nested-lists-to-multidimensional-numpy-arrays
Convert Python Nested Lists to Multidimensional NumPy Arrays - GeeksforGeeks
July 15, 2025 - Initialize the nested 4-dimensional list and then use numpy.asarray() function to convert the list to the array and store it in a different object.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-python-list-to-numpy-arrays
Convert Python List to numpy Arrays - GeeksforGeeks
July 12, 2025 - The numpy.array() function is the most common way to convert a list into an array. It takes the Python list as an argument and returns a NumPy array containing the same elements.
๐ŸŒ
YouTube
youtube.com โ€บ shorts โ€บ yDnwEJ8SEkQ
How To Convert List To Numpy Array In Python - YouTube
In this python tutorial, I show you how to convert list to numpy array in python! Let's get coding!======== Ask Case Digital ========If you have a question y...
Published: December 18, 2024
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what is the correct of way of creating a list of matrices in numpy
r/learnpython on Reddit: What is the correct of way of creating a list of matrices in numpy
July 31, 2022 -

Here is my code:

b = np.empty((0,2,2), dtype = float)
a = np.empty((0,2), dtype=float)
a = np.append(a,[(3,4)], axis=0)
a = np.append(a,[(5,6)], axis=0)
display(a)
print (a[np.newaxis].shape)
print (b.shape)

b = np.append(b, a[np.newaxis], axis=0)
display(b)
a = np.empty((0,2), dtype=float)
a = np.append(a,[(3.5,4)], axis=0)
a = np.append(a,[(5.2,6)], axis=0)
display(a)

np.append(b, a[np.newaxis], axis=0)

A couple of things feel clumsy to me. The main thing is having to specify the size of most of the dimensions of the matrix and not just the size of it. For instance I really just want to create a list of matrices but why do I need to specify whether it's a list of 2x2 matrices as apposed to 5x2 matrices and unless I preadvise the code, in the np.empty statement, it brings up an error.

Update: Here is the output I get. https://images.kiwiheretic.xyz/jupyter-output1.png

Is numpy really this rigid as python lists are not nearly as fussy?

๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ how to convert python list to numpy arrays?
How to Convert Python List to NumPy Arrays? - Analytics Vidhya
April 21, 2025 - Additionally, NumPy arrays offer various benefits, such as memory efficiency, broadcasting, and seamless integration with other libraries. The simplest way to convert a Python list to a NumPy array is by using the `numpy.array()` function.