AnsweredAssumed Answered

Numpy Array Gets Reshaped when Assigning Dtype

Question asked by mitchh300 on Oct 12, 2017
Latest reply on Oct 13, 2017 by Dan_Patterson

Essentially, I need to get a Numpy array (rows = x, cols = 3) to a geodatabase table.  What is happening is when I specify the dtype of the array to get the field names / types for the table, the array gets reshaped.



Any ideas?

#format array to create table from
#array of nearest values... reshaped to: rows=(inXY * toReturn), columns=3
formArray = numpy.array(listArray).reshape(-1,3)

dts = [('IN_OID', '<i4'),('NEAR_OID', '<i4'),('NEAR_DIST', '<f8')]

finalArray = numpy.rec.fromrecords(formArray, dtype = dts)

#export to geodatabase table
arcpy.da.NumPyArrayToTable(finalArray, r'...\ArcGIS\Default.gdb\out_table')



How the array structure should look:                                                 How the array looks after specifying dtype


And this is what the output table looks like (notice it has 60 rows... it should only contain 20)