Why can I not reproduce a nd array manually?

拈花ヽ惹草 提交于 2020-05-17 06:21:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!