I am trying to map a list of numpy arrays (containing a single string) to an array of arrays. I want this because I need it to be in that specific format to save it to a .mat file.
I currently have the following:
var1 = [array(['String1'], dtype='<U9'), array(['String2'], dtype='<U9'), ...]
var2 = np.asarray(var1)
output when printing var2:
[['String1']
['String2']
['String3']
...]
It seems like it is creating a list of lists instead of an array of arrays of some sort. Might it be that .asarray simply can't handle 2D arrays and I need another function? Or am I making a simple mistake here.
Expected output:
array([[array(['String1'], dtype='<U9'),
array(['String2'], dtype='<U9'),
array(['String3'], dtype='<U9'),
...]], dtype=object)
array(...)because you printed it out and python decided to just show you the data within it. but if you dotype(var2), it is an numpy array. Or if you just typevar2in your python prompt, you see what you want to see. Each of the element inside yourvar2is also array.