Edit: here's the current code I've got so far:
itsct_nparr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>FeatureClassToNumPyArray<SPAN class="punctuation token">(</SPAN>prItsct<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'FID_preproc'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NAME'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'Shape_Area'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#create a pandas DataFrame objects from the NumPy arrays</SPAN>
itsct_df <SPAN class="operator token">=</SPAN> DataFrame<SPAN class="punctuation token">(</SPAN>itsct_nparr<SPAN class="punctuation token">,</SPAN> columns<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'FID_preproc'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NAME'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'Shape_Area'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
maxarea <SPAN class="operator token">=</SPAN> itsct_df<SPAN class="punctuation token">.</SPAN>groupby<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'FID_preproc'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NAME'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> as_index<SPAN class="operator token">=</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>max<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
maxarea<SPAN class="punctuation token">.</SPAN>to_csv<SPAN class="punctuation token">(</SPAN>csvout<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> itsct_nparr<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I need to come up with a solution that allows me to summarize an input table, performing a GroupBy on 2 columns ("FID_preproc" and "Shape_Area") and keep all of the fields in the original table in the output/result. From there I'll be joining that result with another table and calculating a field using the NAME column.
From the example, I need to maintain the FID_preproc, and NAME fields (see the desired result). GroupBy on FID_preproc and MAX(Shape_Area).
Any method is acceptable (numpy, pandas, summarize table, da.SearchCursor, etc.) -- whatever you have I can use!
| Input: | | |
| FID_preproc | NAME | Shape_Area |
| 1340 | A | 25952.35775 |
| 1341 | A | 118099.5219 |
| 1341 | B | 305220.1244 |
| 1342 | A | 12053.13585 |
| | |
| Desired Result: | | |
| FID_preproc | NAME | Shape_Area |
| 1340 | A | 25952.35775 |
| 1341 | B | 305220.1244 |
| 1342 | A | 12053.13585 |