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 October 04, 2018 09:22 AM

Updated May 12, 2018 08:22 AM

Updated November 26, 2018 14:22 PM

Updated May 02, 2018 12:22 PM

Updated November 19, 2018 22:22 PM