Hi I'm having trouble returning the total sum of my value field to my updateFC for each row within the update feature class. Any pointers would be appreciated.
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">'C:\Users\michellep\Documents\project.gdb'</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Arcpy & Numpy Successfully Imported"</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Start Processing"</SPAN>
start <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>time<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
sourceFC <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Test_Group'</SPAN>
sourceFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'ID_Data'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'KV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'AV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Total'</SPAN><SPAN class="punctuation token">]</SPAN>
pc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\Users\michellep\Documents\Data\Table.dbf'</SPAN>
PCFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'AV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'KV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'WV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'B'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'kW'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Value'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#create dict of test group</SPAN>
valueDict <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>r<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">(</SPAN>r<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> r <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>sourceFC<SPAN class="punctuation token">,</SPAN> sourceFields<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">#point to update FC test_group_1</SPAN>
updateFC <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Test_Group_1'</SPAN>
updateFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'ID_Data'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'KV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'AV'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Total'</SPAN><SPAN class="punctuation token">]</SPAN>
updateCursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>updateFC<SPAN class="punctuation token">,</SPAN> updateFields<SPAN class="punctuation token">)</SPAN>
updatePC <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>pc<SPAN class="punctuation token">,</SPAN> PCFields<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> UpdateRow <SPAN class="keyword token">in</SPAN> updateCursor<SPAN class="punctuation token">:</SPAN>
keyValue <SPAN class="operator token">=</SPAN> UpdateRow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">if</SPAN> keyValue <SPAN class="keyword token">in</SPAN> valueDict<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> updatePC<SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> valueDict<SPAN class="punctuation token">[</SPAN>keyValue<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> valueDict<SPAN class="punctuation token">[</SPAN>keyValue<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">/</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">/</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">*</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN>
updatePC<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
arr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>TabletoNumPyArray<SPAN class="punctuation token">(</SPAN>pc<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Value"</SPAN><SPAN class="punctuation token">)</SPAN>
arr<SPAN class="punctuation token">.</SPAN>dtype <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>dtype<SPAN class="punctuation token">(</SPAN>float<SPAN class="punctuation token">)</SPAN>
UpdateRow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>sum<SPAN class="punctuation token">(</SPAN>arr<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> row
updateCursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>UpdateRow<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> UpdateRow
end <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>time<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
processTime <SPAN class="operator token">=</SPAN> end <SPAN class="operator token">-</SPAN> start
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Processing Completed - {:.1f} seconds"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>processTime<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>