问题
I'm confused about these data structures.
From a GIS system, I use a function to extract the meta data (8 different fields)
myList = FeatureClassToNumPyArray(...)
myList = [('a', 'b', 'c'...) ('aa', 'bb', 'cc'...) ..] # 8 fields
print (type(myList ))
print (myList.shape)
print (myList.size)
This produces:
<class 'numpy.ndarray'>
(1, 9893)
9893
# I was expecting to get (9893 rows x 8 cols), as in (8,9893)
# or (9893, 8), but anyway, let's not worry about that right now.
So I try this:
>>> source = [('a', 'b', 'c') ('aa', 'bb', 'cc')]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable
But throw in a comma separator, and it's fine... but now it's a list.
>>> source = [('a', 'b', 'c'), ('aa', 'bb', 'cc')]
>>> type(source)
<class 'list'>
So, this magical GIS function can produce a data structure that is accepted as a numpy data array, but if I try create it manually, it's not possible.
What am I missing?
来源:https://stackoverflow.com/questions/61784860/why-can-i-not-reproduce-a-nd-array-manually