Well, I actually ended up solving it by installing pandasql which is able to run SQL queries on dataframes. Howeverm this is such a simple task to perform on a table that a more standard approach must exist (pandasql doesn't even come with Anaconda).
I thought about just creating two separate columns for sum(revenue) and count(distinct citizen) and then dividing one by the other, but I'd like to be able to do it in one go.
So basically I circumvented the problem, I have no idea how to solve it "directly".