Below is the code I am struggling with as a beginner:
commonfields = arcpy.ListFields(gt_pnts)
names = [f.name for f in commonfields]
needed_names = names[3:]
gt_pnts_arr = arcpy.da.FeatureClassToNumPyArray(gt_pnts, needed_names)
gt_pnts_arr = gt_pnts_arr.reshape((gt_pnts_arr.shape[0],1))
eq_smpled_pnts_arr = arcpy.da.FeatureClassToNumPyArray(eq_smpled_pnts, needed_names)
eq_smpled_pnts_arr = eq_smpled_pnts_arr.reshape((eq_smpled_pnts_arr.shape[0],1))
master_table = np.concatenate((gt_pnts_arr, eq_smpled_pnts_arr), axis=0)
np.savetxt(outputcsvfilename,master_table, fmt="%.1f")
Error is as below:
TypeError: float argument required, not numpy.void
I searched and found this exception raised when datatype is not defined. But when I test as below I am in the dilemma-
>>>master_table.dtype.descr
>>>[('grid_code', '<i4'), ('b1_Clip_ProximityRaster1', '<f4'), ('b2_Clip_ProximityRaster1', '<f4'), ('b3_Clip_ProximityRaster1', '<f4'), ('b4_Clip_ProximityRaster1', '<f4'), ('b5_Clip_ProximityRaster1', '<f4'), ('b6_Clip_ProximityRaster1', '<f4'), ('b7_Clip_ProximityRaster1', '<f4'), ('b8_Clip_ProximityRaster1', '<f4'), ('b9_Clip_ProximityRaster1', '<f4'), ('b10_Clip_ProximityRaster1', '<f4'), ('b11_Clip_ProximityRaster1', '<f4'), ('b12_Clip_ProximityRaster1', '<f4'), ('b13_Clip_ProximityRaster1', '<f4'), ('resp', '<U2')]
>>>master_table
array([[ (13, 13.0, 3810.0, 3810.0, 1982.952392578125, 3873.71923828125, 34869.9140625, 5483.3564453125, 7272.138671875, 4409.591796875, 872.0665283203125, 36238.62109375, 4441.62109375, 6775.2861328125, u'1')],
[ (1, 1.0, 3601.99951171875, 3603.12353515625, 1626.9295654296875, 3725.922607421875, 34595.9453125, 5810.5595703125, 7592.90478515625, 4476.0361328125, 576.2811889648438, 36462.984375, 4499.0, 7164.47509765625, u'1')],
[ (13, 13.0, 3721.93505859375, 3723.02294921875, 1642.3458251953125, 3842.928466796875, 34713.43359375, 5702.3681640625, 7597.17041015625, 4562.07177734375, 657.9513549804688, 36343.12890625, 4586.9599609375, 7111.0126953125, u'1')],.....................
>>>master_table.shape
>>>(50, 1)
>>>gt_pnts_arr.shape
>>>(25, 1)
Even I can not load this master_table into pandas dataframe as below-
df = pd.DataFrame(data=master_table[1:,1:], index=master_table[1:,0],columns=master_table[0,1:])
My table datatypes:
There are 13 colums and 50 rows in the master_table.First and last column datatype is respectively integer and integer but all other(11) data type is float.
master_tableis non numerical because of the last column ofu'1''s, and it also contains python tuples instead of being multidimensional with floats. You probably just need to reformat your data...savetxt. It can handle 1d structured arrays also, but getting thefmtright can trickier. The code isn't complicated - just iterate and format the 'row' withfmt%tuple(row). The numpy void is a record of your structured array.