# Calculating summary statistics of table while prioritising certain values

I have a data set of species each of which is assigned a score, for each spatially joined location (grid square) I need to find the sum score of unique species. There is a complication in that subspecies are involved, where a subspecies and parent species are present in the same location, only the score from the subspecies should be taken.

See below for an example

``````    Species     Site   Score
SppA         1      5
SppB         1      1
SppASsp1     1      1
SppA         1      5
SppA         2      5
SppB         2      1
SppA         2      5
``````

In the above example, site 1 would score `2`, as the score for SppASsp1 (the subspecies) would be prioritised over SppA (The parent species) along with SppB. Site 2 would score `6` as only SppA is present along with SppB.

Is there anyway to achieve this using ArcGIS Pro or otherwise (QGIS, Python, Pandas perhaps?), I have undertake a crude analysis using Summarize within but this doesn't allow to prioritise certain values. I feel I would need to make an additional column (eg priority) but am not sure how to progress beyond this.

I would like the output to comprise unique species and prioritised subspecies where applicable, the above example would look like this:

``````    Species     Site   Score
SppB         1      1
SppASsp1     1      1
SppB         2      1
SppA         2      5
``````

this would then allow me to use summary statistics to calculate the final site score:

``````Site   Score
1      2
2      6
``````
• Could you please provide an example of the desired output with an explanation?
– Aaron
Aug 14, 2020 at 14:01
• The prefix of a subspecies is always `Ssp1`? How many different subspecies can one specie have?
– BERA
Aug 14, 2020 at 15:00
• It would be Ssp_something. The largest number of subspecies in the dataset is 3, where multiple subspecies are present it should also accept multiple unique subspecies. Aug 14, 2020 at 15:09
• I think this is pretty complicated. You could ask this as a pandas question on stackoverflow where there are pandas experts. The dataframe can be created using da.SearchCursor and pd.DataFrame.from_records
– BERA
Aug 14, 2020 at 15:36
• I think this is doable using ArcPy so I think you should narrow the focus of your question to that and start writing some code to see where or if you get stuck.
– PolyGeo
Aug 14, 2020 at 20:38