I have a dataset given below:
import pandas as pd
data = pd.DataFrame({'A': ["A", "A", "A", "B", "B", "B", "A", "A", "A", "A", "B"],
'B': ["C", "D", "C", "C", "D", "C", "C", "D", "D", "C", "D"],
'C': ["A1", "A2", "A1", "A1", "A2", "A3", "A4", "A2", "A1", "A1", "A2"])
I need to have a function, func(List[str]) -> List[int]
, that takes the column names and returns me to get frequencies illustrated with given examples:
func(["A"]) -> [7, 4]
func(["A", "B"]) -> [4, 3, 2, 2]
Is there any way to solve this problem efficiently?