I have a dataframe with multiple columns and I want to apply different functions on each column.
An example of my dataset -
I want to calculate the count
of column pq110a for each country mentioned in qcountry2 column(me-mexico,br-brazil,ar-argentina). The problem I face here is that I have to use filter on these columns for example for sample patients I want-
- Count of pq110 when the values are 1 and 2 (for some patients)
- Count of pq110 when the value is 3 (for another patients)
- Similarly when the value is 6.
- For total patient I want-total count of pq110.
Output I am expecting is-Output
Similalry for each country I want this output.
Please suggest how can I do this for other columns also,countrywise.
Thanks !!