How to query attribute table in QGIS to return the sum of a subset

by Overlord84   Last Updated October 08, 2018 04:22 AM

I am using Jupyter notebook to query a dataset too big to be opened with excel and my pc is too slow to perform calculations directly on QGIS.

My logic is as follows, after imported pandas:

x = df[(df.OBJECTID == 4440) & (df.Landuse == 'Grass - Urban')]
want_area = x['Area'].sum() #returning the whole dataframe sum for that field!!
summed = x['Area'].sum() 
ratio = round(want_area / summed, 2)

How can I tweak the code in order to obtain the sum of the 'Area' of the above subset only, and not for the whole dataframe (800+ thousand features)?

Hope my simple question makes sense and thank you very much!

Related Questions

Updated February 25, 2019 13:22 PM

Updated October 04, 2018 09:22 AM

Updated May 14, 2019 21:22 PM

Updated May 12, 2018 08:22 AM

Updated February 13, 2019 10:22 AM