I would like to group values in a field in an attribute table. The field contains duplicate values. These duplicate values should be grouped based on duplicate values, the field would look something like the arbitrary 'Field' below:
Field Date Flagged_Field X 1/1/2014 X 1/1/2013 X 1/1/2015 Y Y 1/1/2000 Y 1/1/2008 Y Z 1/1/1999 Z 1/1/1998 Z 1/1/1992 Z 1/1/2003 Y
Values X, Y and Z which are duplicate records would then be grouped. Ideally I would like to proceed to use if, elif and else to compare other fields within the group containing the value X for Field and once finished move on to the group contain the value Y and lastly Z.
Here's what I have:
cursor = arcpy.SearchCursor(fc) row = cursor.next() for row in cursor: rowField = (row.getValue("Field")) listC = ([list(j) for i, j in groupby(rowField)]) for groups in listC: print str(groups)
What happens is I get a list of unicode for each letter in the field. I believe if I can somehow compare the field values against each other as opposed to the characters in just one field I can get close to what I need with this.
I'm trying to gather all like values based on attributes, specifically one field. I would then like to, using these like values compare other attributes of the data. For example I have a date field which, based on like values in the Field shown in my above example I would like to flag the record containing the most recent date, see revisions above.